Skip to content

[Discover][Field Formatter] Fix handling of missing values#251892

Merged
jughosta merged 11 commits intoelastic:mainfrom
jughosta:251846-fix-field-formatters
Feb 9, 2026
Merged

[Discover][Field Formatter] Fix handling of missing values#251892
jughosta merged 11 commits intoelastic:mainfrom
jughosta:251846-fix-field-formatters

Conversation

@jughosta
Copy link
Contributor

@jughosta jughosta commented Feb 5, 2026

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

@jughosta jughosta self-assigned this Feb 5, 2026
@jughosta jughosta added release_note:fix Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// backport:version Backport to applied version labels v9.3.1 v9.2.6 labels Feb 5, 2026
@jughosta jughosta requested a review from Copilot February 5, 2026 15:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 checkForMissingValueText and checkForMissingValueHtml helper methods to the base FieldFormat class 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
@kibanamachine
Copy link
Contributor

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.

see run history

@kibanamachine
Copy link
Contributor

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.

see run history

@kibanamachine
Copy link
Contributor

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.

see run history

@kibanamachine
Copy link
Contributor

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.

see run history

@kibanamachine
Copy link
Contributor

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.

see run history

@jughosta jughosta marked this pull request as ready for review February 6, 2026 13:55
@jughosta jughosta requested a review from a team as a code owner February 6, 2026 13:55
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested URL and badge scenario, both work as expected 👍

Comment on lines 220 to 236
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>`;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these methods be protected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated via 3170700

Thanks for the suggestion!

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #38 / Agent Builder tools MCP tools creating MCP tools should create an MCP tool by selecting connector and tool

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
fieldFormats 251 282 +31

Any counts in public APIs

Total count of every any typed public API. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats any for more detailed information.

id before after diff
fieldFormats 6 14 +8

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fieldFormats 58.4KB 59.9KB +1.5KB
Unknown metric groups

API count

id before after diff
fieldFormats 290 321 +31

History

cc @jughosta

@jughosta jughosta merged commit deec23d into elastic:main Feb 9, 2026
16 checks passed
@jughosta jughosta deleted the 251846-fix-field-formatters branch February 9, 2026 12:21
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 9.2, 9.3

https://github.com/elastic/kibana/actions/runs/21824881060

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Feb 9, 2026
…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)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Feb 9, 2026
…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)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
9.2
9.3

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Feb 9, 2026
…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>
kibanamachine added a commit that referenced this pull request Feb 9, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:fix Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// v9.2.6 v9.3.0 v9.3.1 v9.4.0

5 participants