Skip to content

fix: prevent false "data source not set" error on markdown dashboard tiles#2202

Open
vinzee wants to merge 1 commit intohyperdxio:mainfrom
vinzee:va/fix-mcp-dashboard-text-tiles
Open

fix: prevent false "data source not set" error on markdown dashboard tiles#2202
vinzee wants to merge 1 commit intohyperdxio:mainfrom
vinzee:va/fix-mcp-dashboard-text-tiles

Conversation

@vinzee
Copy link
Copy Markdown
Contributor

@vinzee vinzee commented May 5, 2026

Problem

Markdown tiles created via the external API or MCP always show the following error:

The data source for this tile is not set. Edit the tile to select a data source.

...even though markdown tiles do not require a data source. Tiles created through the UI do not exhibit this problem.

Root Cause

convertToInternalTileConfig stores source: '' on the internal config for markdown tiles to satisfy the BuilderSavedChartConfig TypeScript type, which requires a source field:

case 'markdown':
  internalConfig = {
    displayType: DisplayType.Markdown,
    markdown: externalConfig.markdown,
    source: '',   // <-- required by type, but semantically empty
    ...
  } satisfies BuilderSavedChartConfig;

The frontend's isSourceUnset check in DBDashboardPage used
!chart.config.source, which evaluates to true for an empty string,
incorrectly triggering the error banner for every API-created markdown tile:

const isSourceUnset =
  !!chart.config &&
  isBuilderSavedChartConfig(chart.config) &&
  !chart.config.source;  // true for '', fires on all markdown tiles

Solution

Add a displayType !== DisplayType.Markdown guard to isSourceUnset so
markdown tiles are never considered to have an unset source:

const isSourceUnset =
  !!chart.config &&
  isBuilderSavedChartConfig(chart.config) &&
  chart.config.displayType !== DisplayType.Markdown &&
  !chart.config.source;

Tests

  • packages/common-utils: unit tests for isBuilderSavedChartConfig and
    the isSourceUnset pattern, verifying that markdown tiles evaluate to
    false (no error shown) even when source is ''
  • packages/api: unit tests for convertToInternalTileConfig covering
    the markdown tile conversion path and tile layout field preservation

@vercel
Copy link
Copy Markdown

vercel Bot commented May 5, 2026

@vinzee is attempting to deploy a commit to the HyperDX Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 5, 2026

🦋 Changeset detected

Latest commit: bcfb9b4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@hyperdx/app Patch
@hyperdx/common-utils Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

PR Review

✅ The fix is correct and well-targeted. displayTypeRequiresSource cleanly centralizes the exclusion logic.

  • ⚠️ Multi-line comment block in guards.ts violates project style (AGENTS.md: "Never write multi-paragraph docstrings or multi-line comment blocks — one short line max") → Collapse the 4-line JSDoc to a single // line
  • ⚠️ Multi-line comment blocks in test files (guards.test.ts lines 67–71, 113–116; dashboards.test.ts lines 57–61) → Same rule applies; remove or collapse to one line each
  • ℹ️ Number display type is not covered by displayTypeRequiresSource tests — if Number tiles ever omit a source (similar to Markdown), this would re-emerge. Not a blocker since Number currently always needs a source, but worth noting for future additions to the enum.

@vinzee vinzee force-pushed the va/fix-mcp-dashboard-text-tiles branch from a091a1b to 923869d Compare May 5, 2026 21:01
…d tiles

Markdown tiles created via the external API or MCP always showed
\"The data source for this tile is not set. Edit the tile to select
a data source.\" in the dashboard UI, despite not requiring a source.

Root cause: convertToInternalTileConfig stores source: '' on the
internal config to satisfy BuilderSavedChartConfig's required source
field. The frontend's isSourceUnset check used !chart.config.source,
which evaluates to true for an empty string, incorrectly triggering
the error banner for every API-created markdown tile.

Fix: add chart.config.displayType !== DisplayType.Markdown to the
isSourceUnset guard in DBDashboardPage so markdown tiles are never
considered to have an unset source.

Tests added:
- packages/common-utils: unit tests for isBuilderSavedChartConfig and
  the isSourceUnset pattern, verifying markdown tiles are excluded
- packages/api: unit tests for convertToInternalTileConfig covering
  the markdown tile conversion and layout field preservation

Co-authored-by: Cursor <cursoragent@cursor.com>
@vinzee vinzee force-pushed the va/fix-mcp-dashboard-text-tiles branch from 923869d to bcfb9b4 Compare May 5, 2026 21:07
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.

1 participant