fix: handle non-string title in export dashboard standardization - #3792
Merged
Conversation
In Kibana dashboard JSON, axis config objects (embeddableConfig.axis.x/y/y2)
use "title" as a nested map (e.g. {"visible": false}) rather than a string.
The previous direct type assertion panicked in those cases. Switch to a safe
assertion so non-string title values fall through to the general map/array
recursion unchanged.
Add unit tests covering: string title with/without ECS suffix, map-typed
title (axis case), nested and array traversal, and markdown link ID
adjustment.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
Tested again with the changes in this PR elastic/integrations#20265 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
elastic-package export dashboardspanicked when processing Kibana dashboardsthat contain XY chart panels. The root cause was an unsafe type assertion in
standardizeObjectProperties: the code assumed thetitlekey was always astring, but in axis config objects (embeddableConfig.axis.x/y/y2) it is anested map like
{"visible": false}.Example (snippet from dashboard export):
{ "x": { "domain": { "rounding": false, "type": "fit" }, "grid": { "visible": true }, "labels": { "orientation": "horizontal" }, "scale": "temporal", "ticks": { "visible": true }, "title": { "visible": false } }, "y": { "domain": { "rounding": true, "type": "full" }, "grid": { "visible": true }, "labels": { "orientation": "horizontal" }, "scale": "linear", "ticks": { "visible": true }, "title": { "visible": false } } }Changes
internal/export/transform_standardize.go: Replace the direct typeassertion
value.(string)for thetitlekey with a safe assertion. Whentitleis not a string, the transformation is skipped and the value fallsthrough to the general map/array recursion unchanged.
internal/export/transform_standardize_test.go(new): Unit tests forstandardizeObjectPropertiescovering:ECSsuffixadjustObjectIDTested with dashboards defined in elastic/integrations#20265
Proposed commit