Skip to content

Commit c64ef55

Browse files
betegonclaude
andcommitted
fix(dashboard): validate aggregates when --dataset changes without --query
Changing --dataset (e.g. discover→spans) without --query skipped aggregate validation, allowing dataset-incompatible aggregates like failure_rate() to be sent with widgetType: "spans". Now validates existing aggregates against the new dataset too. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8451208 commit c64ef55

File tree

1 file changed

+7
-6
lines changed
  • src/commands/dashboard/widget

1 file changed

+7
-6
lines changed

src/commands/dashboard/widget/edit.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,13 @@ function buildReplacement(
8585
): DashboardWidget {
8686
const mergedQueries = mergeQueries(flags, existing.queries?.[0]);
8787

88-
// Validate aggregate names if query flags were provided
89-
if (flags.query && mergedQueries?.[0]?.aggregates) {
90-
validateAggregateNames(
91-
mergedQueries[0].aggregates,
92-
flags.dataset ?? existing.widgetType
93-
);
88+
// Validate aggregates when query or dataset changes — prevents broken widgets
89+
// (e.g. switching --dataset from discover to spans with discover-only aggregates)
90+
const newDataset = flags.dataset ?? existing.widgetType;
91+
const aggregatesToValidate =
92+
mergedQueries?.[0]?.aggregates ?? existing.queries?.[0]?.aggregates;
93+
if ((flags.query || flags.dataset) && aggregatesToValidate) {
94+
validateAggregateNames(aggregatesToValidate, newDataset);
9495
}
9596

9697
const limit = flags.limit !== undefined ? flags.limit : existing.limit;

0 commit comments

Comments
 (0)