Skip to content

fix: handle non-string title in export dashboard standardization - #3792

Merged
mrodm merged 1 commit into
elastic:mainfrom
mrodm:fix_export_dashboards
Jul 30, 2026
Merged

fix: handle non-string title in export dashboard standardization#3792
mrodm merged 1 commit into
elastic:mainfrom
mrodm:fix_export_dashboards

Conversation

@mrodm

@mrodm mrodm commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

elastic-package export dashboards panicked when processing Kibana dashboards
that contain XY chart panels. The root cause was an unsafe type assertion in
standardizeObjectProperties: the code assumed the title key was always a
string, but in axis config objects (embeddableConfig.axis.x/y/y2) it is a
nested 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 type
    assertion value.(string) for the title key with a safe assertion. When
    title is not a string, the transformation is skipped and the value falls
    through to the general map/array recursion unchanged.
  • internal/export/transform_standardize_test.go (new): Unit tests for
    standardizeObjectProperties covering:
    • String title with/without ECS suffix
    • Map-typed title (the axis config case) — no panic, value preserved
    • Nested map and array traversal
    • Markdown link rewriting via adjustObjectID

Tested with dashboards defined in elastic/integrations#20265

Proposed commit

fix: handle non-string title values in standardizeObjectProperties

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.

This PR was generated with the assistance of Claude (claude-sonnet-4-6).

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>
@mrodm mrodm self-assigned this Jul 29, 2026
@mrodm
mrodm marked this pull request as ready for review July 29, 2026 10:05
@mrodm
mrodm requested a review from a team as a code owner July 29, 2026 10:05
@mrodm
mrodm requested a review from ishleenk17 July 29, 2026 10:05

@teresaromero teresaromero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🐛 thanks!

@mrodm

mrodm commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Tested again with the changes in this PR elastic/integrations#20265
before they were updated to 9.4.3 (using changeset elastic/integrations@8d6cd21)

@mrodm
mrodm merged commit fb0b43d into elastic:main Jul 30, 2026
4 checks passed
@mrodm
mrodm deleted the fix_export_dashboards branch July 30, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants