Skip to content

Commit 2b80896

Browse files
betegonclaude
andcommitted
fix(dashboard): validate only tracked display types in buildReplacement
The previous fix used `if (flags.display || isTrackedDisplay)` which still triggered validateWidgetEnums when the user passed --display with an untracked type (e.g. text), causing a spurious ValidationError. Simplify to just `if (isTrackedDisplay)` — untracked display types carry no dataset constraints regardless of how the flag was set. Also adds a test covering --display text to prevent regression. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6b65f8f commit 2b80896

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/commands/dashboard/widget/edit.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,16 @@ function buildReplacement(
105105
// Validating them against a dataset would always fail, blocking legitimate edits like
106106
// changing --dataset on a text widget.
107107
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.
108112
const isTrackedDisplay = Object.values(
109113
DATASET_SUPPORTED_DISPLAY_TYPES
110114
).some((types) =>
111115
(types as readonly string[]).includes(effectiveDisplay ?? "")
112116
);
113-
if (flags.display || isTrackedDisplay) {
117+
if (isTrackedDisplay) {
114118
validateWidgetEnums(effectiveDisplay, effectiveDataset);
115119
}
116120
}

test/commands/dashboard/widget/edit.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,16 @@ describe("dashboard widget edit", () => {
271271
expect(updateDashboardSpy).toHaveBeenCalled();
272272
});
273273

274+
test("allows --display change to untracked display type (text)", async () => {
275+
// Changing --display to an untracked type should also skip cross-validation.
276+
const { context } = createMockContext();
277+
const func = await editCommand.loader();
278+
// sampleDashboard widget[0] is displayType: "big_number", widgetType: "spans"
279+
// Changing to "text" should not throw even though "text" isn't in spans' supported types.
280+
await func.call(context, { json: false, index: 0, display: "text" }, "123");
281+
expect(updateDashboardSpy).toHaveBeenCalled();
282+
});
283+
274284
test("validates aggregates against new dataset when --dataset changes", async () => {
275285
const { context } = createMockContext();
276286
const func = await editCommand.loader();

0 commit comments

Comments
 (0)