Skip to content

Commit c6fa5e9

Browse files
betegonclaude
andcommitted
fix(dashboard): move untracked-display guard into validateWidgetEnums
The isTrackedDisplay check was only applied in buildReplacement, but validateWidgetEnums is also called early in both edit and add (before any widget fetching) with the raw flags. Passing --display text --dataset spans would still throw there, contradicting the documented behavior that untracked types (text, wheel, rage_and_dead_clicks, agents_traces_table) "bypass Sentry's dataset system entirely and have no constraints." Move the guard into validateWidgetEnums itself so the fix applies to all callers uniformly. buildReplacement can now call validateWidgetEnums directly without duplicating the logic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2b80896 commit c6fa5e9

File tree

2 files changed

+15
-26
lines changed

2 files changed

+15
-26
lines changed

src/commands/dashboard/resolve.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,19 @@ export function validateWidgetEnums(display?: string, dataset?: string): void {
384384
);
385385
}
386386
if (display && dataset) {
387-
const supported = DATASET_SUPPORTED_DISPLAY_TYPES[dataset as WidgetType];
388-
if (supported && !(supported as readonly string[]).includes(display)) {
389-
throw new ValidationError(
390-
`The "${dataset}" dataset supports: ${supported.join(", ")}. Got: "${display}".`,
391-
"display"
392-
);
387+
// Untracked display types (text, wheel, rage_and_dead_clicks, agents_traces_table)
388+
// bypass Sentry's dataset query system entirely — no dataset constraint applies.
389+
const isTrackedDisplay = Object.values(
390+
DATASET_SUPPORTED_DISPLAY_TYPES
391+
).some((types) => (types as readonly string[]).includes(display));
392+
if (isTrackedDisplay) {
393+
const supported = DATASET_SUPPORTED_DISPLAY_TYPES[dataset as WidgetType];
394+
if (supported && !(supported as readonly string[]).includes(display)) {
395+
throw new ValidationError(
396+
`The "${dataset}" dataset supports: ${supported.join(", ")}. Got: "${display}".`,
397+
"display"
398+
);
399+
}
393400
}
394401
}
395402
}

src/commands/dashboard/widget/edit.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { formatWidgetEdited } from "../../../lib/formatters/human.js";
1313
import { CommandOutput } from "../../../lib/formatters/output.js";
1414
import { buildDashboardUrl } from "../../../lib/sentry-urls.js";
1515
import {
16-
DATASET_SUPPORTED_DISPLAY_TYPES,
1716
type DashboardDetail,
1817
type DashboardWidget,
1918
type DashboardWidgetQuery,
@@ -74,7 +73,6 @@ function mergeQueries(
7473
}
7574

7675
/** Build the replacement widget object by merging flags over existing */
77-
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: merging + validating widget flags requires several conditional branches
7876
function buildReplacement(
7977
flags: EditFlags,
8078
existing: DashboardWidget
@@ -98,25 +96,9 @@ function buildReplacement(
9896
// Re-validate after merging with existing values. validateWidgetEnums only
9997
// checks the cross-constraint when both args are provided, so it misses
10098
// e.g. `--dataset preprod-app-size` on a widget that's already `table`.
101-
//
102-
// Scope: only cross-validate when effectiveDisplay is a tracked type (present in
103-
// DATASET_SUPPORTED_DISPLAY_TYPES). Untracked types — text, wheel, rage_and_dead_clicks,
104-
// agents_traces_table — bypass Sentry's dataset system entirely and have no constraints.
105-
// Validating them against a dataset would always fail, blocking legitimate edits like
106-
// changing --dataset on a text widget.
99+
// validateWidgetEnums itself skips untracked display types (text, wheel, etc.).
107100
if (flags.display || flags.dataset) {
108-
// Only cross-validate when effectiveDisplay is a tracked type (present in
109-
// DATASET_SUPPORTED_DISPLAY_TYPES). Untracked types — text, wheel,
110-
// rage_and_dead_clicks, agents_traces_table — bypass Sentry's dataset system
111-
// entirely, so any dataset is valid with them regardless of which flag triggered this.
112-
const isTrackedDisplay = Object.values(
113-
DATASET_SUPPORTED_DISPLAY_TYPES
114-
).some((types) =>
115-
(types as readonly string[]).includes(effectiveDisplay ?? "")
116-
);
117-
if (isTrackedDisplay) {
118-
validateWidgetEnums(effectiveDisplay, effectiveDataset);
119-
}
101+
validateWidgetEnums(effectiveDisplay, effectiveDataset);
120102
}
121103

122104
const raw: Record<string, unknown> = {

0 commit comments

Comments
 (0)