[Discover][Field Formatter] Fix handling of missing values#251892
[Discover][Field Formatter] Fix handling of missing values#251892jughosta merged 11 commits intoelastic:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the handling of missing values (null, undefined, and empty strings) across field formatters in Discover. Several formatters (URL, Badge, Date, and others) had inconsistent or broken behavior when encountering missing values, which could result in rendering errors or confusing output.
Changes:
- Standardized missing value handling across all field formatters to use consistent labels: "(null)" for null/undefined and "(blank)" for empty strings
- Added
checkForMissingValueTextandcheckForMissingValueHtmlhelper methods to the baseFieldFormatclass for reusable missing value handling - Extended test coverage to verify missing value handling for all affected formatters
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/platform/test/functional/apps/management/data_views/_field_formatter.ts |
Added comprehensive functional tests for missing values across all field formatter types and increased browser window height to accommodate more test cases |
src/platform/plugins/shared/field_formats/public/lib/converters/date.ts |
Updated Date formatter to use standardized missing value handling and added htmlConvert method |
src/platform/plugins/shared/field_formats/public/lib/converters/date.test.ts |
Added unit tests for missing value handling in both text and HTML contexts |
src/platform/plugins/shared/field_formats/common/field_format.ts |
Added reusable helper methods for checking and formatting missing values in text and HTML contexts |
src/platform/plugins/shared/field_formats/common/converters/url.ts |
Fixed URL formatter to handle missing values without rendering invalid links |
src/platform/plugins/shared/field_formats/common/converters/url.test.ts |
Added unit tests for missing value handling in URL formatter |
src/platform/plugins/shared/field_formats/common/converters/truncate.ts |
Updated truncate formatter to handle missing values before truncation |
src/platform/plugins/shared/field_formats/common/converters/truncate.test.ts |
Added unit tests for missing value handling in truncate formatter |
src/platform/plugins/shared/field_formats/common/converters/string.ts |
Refactored to use centralized missing value handling helpers |
src/platform/plugins/shared/field_formats/common/converters/string.test.ts |
Enhanced tests to verify missing value handling in both text and HTML contexts |
src/platform/plugins/shared/field_formats/common/converters/relative_date.ts |
Updated relative date formatter with standardized missing value handling |
src/platform/plugins/shared/field_formats/common/converters/relative_date.test.ts |
Added unit tests for missing value handling |
src/platform/plugins/shared/field_formats/common/converters/percent.test.ts |
Added missing value test coverage |
src/platform/plugins/shared/field_formats/common/converters/ip.ts |
Updated IP formatter to use standardized missing value handling |
src/platform/plugins/shared/field_formats/common/converters/ip.test.ts |
Added unit tests for missing value handling |
src/platform/plugins/shared/field_formats/common/converters/geo_point.ts |
Updated geo-point formatter with consistent missing value handling |
src/platform/plugins/shared/field_formats/common/converters/geo_point.test.ts |
Added unit tests for missing value handling |
src/platform/plugins/shared/field_formats/common/converters/duration.ts |
Updated duration formatter to handle missing values |
src/platform/plugins/shared/field_formats/common/converters/duration.test.ts |
Added missing value test cases and updated type signatures |
src/platform/plugins/shared/field_formats/common/converters/date_nanos_shared.ts |
Updated date nanos formatter with standardized missing value handling |
src/platform/plugins/shared/field_formats/common/converters/currency.test.ts |
Added missing value test coverage |
src/platform/plugins/shared/field_formats/common/converters/color.tsx |
Fixed color formatter to handle missing values without applying colors |
src/platform/plugins/shared/field_formats/common/converters/color.test.ts |
Added comprehensive missing value tests and refactored to use a helper function |
src/platform/plugins/shared/field_formats/common/converters/bytes.test.ts |
Added missing value test coverage |
src/platform/plugins/shared/field_formats/common/converters/boolean.ts |
Updated boolean formatter to handle missing values |
src/platform/plugins/shared/field_formats/common/converters/boolean.test.ts |
Added unit tests for missing value handling |
src/platform/plugins/shared/field_formats/common/converters/color.test.ts
Outdated
Show resolved
Hide resolved
Flaky Test Runner Stats🟠 Some tests failed. - kibana-flaky-test-suite-runner#10675[❌] src/platform/test/functional/apps/management/config.ts: 0/10 tests passed. |
Flaky Test Runner Stats🟠 Some tests failed. - kibana-flaky-test-suite-runner#10678[❌] src/platform/test/functional/apps/management/config.ts: 0/10 tests passed. |
Flaky Test Runner Stats🟠 Some tests failed. - kibana-flaky-test-suite-runner#10681[❌] src/platform/test/functional/apps/management/config.ts: 0/10 tests passed. |
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#10686[✅] src/platform/test/functional/apps/management/config.ts: 10/10 tests passed. |
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#10688[✅] src/platform/test/functional/apps/management/config.ts: 15/15 tests passed. |
|
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
davismcphee
left a comment
There was a problem hiding this comment.
Tested URL and badge scenario, both work as expected 👍
| checkForMissingValueText(val: unknown): string | void { | ||
| if (val === '') { | ||
| return EMPTY_LABEL; | ||
| } | ||
| if (val == null || val === MISSING_TOKEN) { | ||
| return NULL_LABEL; | ||
| } | ||
| } | ||
|
|
||
| checkForMissingValueHtml(val: unknown): string | void { | ||
| if (val === '') { | ||
| return `<span class="ffString__emptyValue">${EMPTY_LABEL}</span>`; | ||
| } | ||
| if (val == null || val === MISSING_TOKEN) { | ||
| return `<span class="ffString__emptyValue">${NULL_LABEL}</span>`; | ||
| } | ||
| } |
There was a problem hiding this comment.
Should these methods be protected?
There was a problem hiding this comment.
Updated via 3170700
Thanks for the suggestion!
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Public APIs missing comments
Any counts in public APIs
Page load bundle
History
cc @jughosta |
|
Starting backport for target branches: 9.2, 9.3 |
…51892) - Resolves elastic#251846 ## Summary URL and Badge (for boolean type) field formatters had noticeable issues when field had no data. Some of the other formatters did not use the same style, so I updated it too. Also extended the tests. A regression after elastic#233369 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. (cherry picked from commit deec23d)
…51892) - Resolves elastic#251846 ## Summary URL and Badge (for boolean type) field formatters had noticeable issues when field had no data. Some of the other formatters did not use the same style, so I updated it too. Also extended the tests. A regression after elastic#233369 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. (cherry picked from commit deec23d)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…1892) (#252296) # Backport This will backport the following commits from `main` to `9.2`: - [[Discover][Field Formatter] Fix handling of missing values (#251892)](#251892) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Julia Rechkunova","email":"julia.rechkunova@elastic.co"},"sourceCommit":{"committedDate":"2026-02-09T12:21:40Z","message":"[Discover][Field Formatter] Fix handling of missing values (#251892)\n\n- Resolves https://github.com/elastic/kibana/issues/251846\n\n## Summary\n\nURL and Badge (for boolean type) field formatters had noticeable issues\nwhen field had no data. Some of the other formatters did not use the\nsame style, so I updated it too.\n\nAlso extended the tests.\n\nA regression after https://github.com/elastic/kibana/pull/233369\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"deec23d07a86824f987965dfe97ea421ea6b46f0","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:DataDiscovery","backport:version","v9.4.0","v9.3.1","v9.2.6"],"title":"[Discover][Field Formatter] Fix handling of missing values","number":251892,"url":"https://github.com/elastic/kibana/pull/251892","mergeCommit":{"message":"[Discover][Field Formatter] Fix handling of missing values (#251892)\n\n- Resolves https://github.com/elastic/kibana/issues/251846\n\n## Summary\n\nURL and Badge (for boolean type) field formatters had noticeable issues\nwhen field had no data. Some of the other formatters did not use the\nsame style, so I updated it too.\n\nAlso extended the tests.\n\nA regression after https://github.com/elastic/kibana/pull/233369\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"deec23d07a86824f987965dfe97ea421ea6b46f0"}},"sourceBranch":"main","suggestedTargetBranches":["9.3","9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/251892","number":251892,"mergeCommit":{"message":"[Discover][Field Formatter] Fix handling of missing values (#251892)\n\n- Resolves https://github.com/elastic/kibana/issues/251846\n\n## Summary\n\nURL and Badge (for boolean type) field formatters had noticeable issues\nwhen field had no data. Some of the other formatters did not use the\nsame style, so I updated it too.\n\nAlso extended the tests.\n\nA regression after https://github.com/elastic/kibana/pull/233369\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"deec23d07a86824f987965dfe97ea421ea6b46f0"}},{"branch":"9.3","label":"v9.3.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.2","label":"v9.2.6","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Julia Rechkunova <julia.rechkunova@elastic.co>
…1892) (#252297) # Backport This will backport the following commits from `main` to `9.3`: - [[Discover][Field Formatter] Fix handling of missing values (#251892)](#251892) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Julia Rechkunova","email":"julia.rechkunova@elastic.co"},"sourceCommit":{"committedDate":"2026-02-09T12:21:40Z","message":"[Discover][Field Formatter] Fix handling of missing values (#251892)\n\n- Resolves https://github.com/elastic/kibana/issues/251846\n\n## Summary\n\nURL and Badge (for boolean type) field formatters had noticeable issues\nwhen field had no data. Some of the other formatters did not use the\nsame style, so I updated it too.\n\nAlso extended the tests.\n\nA regression after https://github.com/elastic/kibana/pull/233369\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"deec23d07a86824f987965dfe97ea421ea6b46f0","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:DataDiscovery","backport:version","v9.4.0","v9.3.1","v9.2.6"],"title":"[Discover][Field Formatter] Fix handling of missing values","number":251892,"url":"https://github.com/elastic/kibana/pull/251892","mergeCommit":{"message":"[Discover][Field Formatter] Fix handling of missing values (#251892)\n\n- Resolves https://github.com/elastic/kibana/issues/251846\n\n## Summary\n\nURL and Badge (for boolean type) field formatters had noticeable issues\nwhen field had no data. Some of the other formatters did not use the\nsame style, so I updated it too.\n\nAlso extended the tests.\n\nA regression after https://github.com/elastic/kibana/pull/233369\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"deec23d07a86824f987965dfe97ea421ea6b46f0"}},"sourceBranch":"main","suggestedTargetBranches":["9.3","9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/251892","number":251892,"mergeCommit":{"message":"[Discover][Field Formatter] Fix handling of missing values (#251892)\n\n- Resolves https://github.com/elastic/kibana/issues/251846\n\n## Summary\n\nURL and Badge (for boolean type) field formatters had noticeable issues\nwhen field had no data. Some of the other formatters did not use the\nsame style, so I updated it too.\n\nAlso extended the tests.\n\nA regression after https://github.com/elastic/kibana/pull/233369\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"deec23d07a86824f987965dfe97ea421ea6b46f0"}},{"branch":"9.3","label":"v9.3.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.2","label":"v9.2.6","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Julia Rechkunova <julia.rechkunova@elastic.co>
Summary
URL and Badge (for boolean type) field formatters had noticeable issues when field had no data. Some of the other formatters did not use the same style, so I updated it too.
Also extended the tests.
A regression after #233369
Checklist
release_note:*label is applied per the guidelinesbackport:*labels.