Repository navigation
feat(api): accept exemplar settings on API- and agent-authored tiles - #2809
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 73f9156 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
|
<!-- deep-review --> Deep Review✅ No critical issues found. The three-stage round trip this change set out to fix (input schema →
🟡 P2 — recommended
🔵 P3 nitpicks (4)
Reviewers (2 of 10 returned): testing, learnings-researcher. Dispatched but not returned before output was required: correctness, adversarial, security, api-contract, maintainability, kieran-typescript, agent-native, project-standards. Coverage caveats:
Testing gaps:
|
The merge-base changed after approval.
e5337c3 to
929dfdb
Compare
🔴 Tier 4 — CriticalTouches authentication, tenancy data models, the public API or shipped database config — or substantially changes the query rendering engine, background tasks, the OTel pipeline, image build, or release CI. Why this tier:
Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
929dfdb to
39d5bc8
Compare
E2E Test Results✅ All tests passed • 480 passed • 1 skipped • 1081s
Tests ran across 4 shards in parallel. |
39d5bc8 to
55718a5
Compare
c701502 to
68850ae
Compare
The round-trip test needs two type assertions. Its tile builder takes the display type as a parameter, so `displayType` is the union rather than a literal and TS cannot pick a branch of the external tile config union without it; writing the two configs out separately to avoid that loses the it.each that makes the line and stacked_bar cases symmetrical, which is the point, since both converters handle them in separate blocks. The outward half then stubs a DashboardDocument around the converted tile, which a mongoose document type cannot be built literally.
…check Addresses a review finding on the previous fix. The kind gate ran over every tile in the request, so an unchanged tile whose trace source had since been deleted or changed kind would fail it on every subsequent save — making an unrelated edit elsewhere on the dashboard impossible to persist. Scoped to new and changed tiles on update, mirroring filterChangedHeatmapTiles, which exists for exactly this reason. The existence check in getMissingSources is deliberately left unscoped: it treats every source reference on the dashboard the same way and reports them with one clear message, and singling this field out would be the inconsistency rather than the fix.
…heck too Addresses a review finding on the previous fix, which only went half way. The kind gate was scoped to changed tiles but the existence check was not, so deleting an exemplar trace source still made every later save of that dashboard fail. The two checks now live together and share one exemption: a deleted source and a source whose kind changed are the same situation to whoever hits them, and nobody could predict that one blocks an edit and the other does not. My earlier reasoning for leaving the existence check unscoped — that getMissingSources should treat every source reference alike — weighted mechanical consistency over what actually happens. A missing `sourceId` means the tile cannot render; a missing `exemplarTraceSourceId` means a marker's trace link is dead on a chart that is otherwise fine. That is not worth refusing an unrelated edit over.
…itched on Addresses a review finding on the previous fix. The unchanged-tile exemption keyed on the trace source id, so a tile carrying a source id while exemplars were disabled kept the exemption when an update turned them on. Nothing was following that reference in the meantime, so the source could have been deleted or stopped being a Trace source with no visible effect — and switching markers on then persisted them pointing at nothing. An id nobody was following is not the same as one about to draw markers, so the off-to-on transition is now checked as if the reference were new. A tile whose exemplars were already on keeps the exemption, which is the case that exemption exists for.
4bd3184 to
2260246
Compare
…ay' into jordansimonovski/exemplars-agent-surface # Conflicts: # packages/api/src/routers/external-api/v2/utils/__tests__/dashboards.test.ts
Duplicate code analysis1 new clone introduced by this PR.
If one of these duplicates a helper that already exists, import it instead jscpd compared this branch against |
| seriesLimit: seriesLimitSchema.describe(timeChartSeriesLimitDescription), | ||
| formulas: mcpTileFormulasSchema, | ||
| showOperandSeries: mcpShowOperandSeriesSchema, | ||
| enableExemplars: z |
There was a problem hiding this comment.
🔵 minor — Exemplar field schemas and describe strings copy-pasted into both the line and bar MCP tile schemas
Pull them into shared mcpEnableExemplarsSchema / mcpExemplarTraceSourceIdSchema constants and reference them from both blocks, the same way mcpShowOperandSeriesSchema (line 388) and timeChartSeriesLimitDescription (line 104) already do in this file. As written, the two ~10-line copies can drift apart. The PR's own test calls out exactly that risk.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
…mplars-agent-surface # Conflicts: # packages/api/src/mcp/tools/dashboards/schemas.ts # packages/api/src/routers/external-api/__tests__/dashboards.int.test.ts # packages/api/src/routers/external-api/v2/utils/dashboards.ts
| // validated the expressions against `select`. | ||
| 'formulas', | ||
| 'showOperandSeries', | ||
| 'enableExemplars', |
There was a problem hiding this comment.
🔵 minor — PromQL tiles still drop enableExemplars/exemplarTraceSourceId on an external round trip
The editor offers the exemplar toggle on PromQL tiles (app/src/components/Exemplars/exemplarToggle.ts:58). However, convertPromqlConfigToExternal (line 241) and convertExternalPromqlConfigToInternal (line 850) don't carry either field, so a GET→PUT through the v2 API or MCP turns exemplars off on those tiles. That is the bug this PR fixes for builder tiles. Add both fields to the PromQL time-chart schema and both PromQL converters.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| lineInterpolation: LineInterpolationSchema.optional().describe( | ||
| 'How points are connected: "smooth" (default), "linear", or "step".', | ||
| ), | ||
| enableExemplars: z |
There was a problem hiding this comment.
🔵 minor — Exemplar field definitions and describe strings copied verbatim into two MCP tile schemas
Define one shared mcpExemplarConfigFields object, like the existing mcpStackedTimeChartConfigFields, and spread it into the line, stacked_bar and stacked_line schemas. Then the copy can't drift between tile types.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| "build": "rimraf ./build && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && cp -r ./src/opamp/proto ./build/opamp/", | ||
| "build:vercel": "rimraf ./build && tsc -p tsconfig.vercel.json && tsc-alias -p tsconfig.vercel.json && cp -r ./src/opamp/proto ./build/opamp/", | ||
| "lint": "npx eslint . --ext .ts --max-warnings 302", | ||
| "lint": "npx eslint . --ext .ts --max-warnings 304", |
There was a problem hiding this comment.
🔵 minor — Lint warning cap raised instead of fixing the new warnings
The two new warnings appear to come from the new tests' casts (as ConfigTile['config'], as unknown as DashboardDocument in v2/utils/tests/dashboards.test.ts), which break the repo's "avoid as casts" rule. Type the fixtures with satisfies or a typed builder and keep the cap at 302.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| "dev-task": "DOTENV_CONFIG_PATH=.env.development nodemon --exec 'ts-node' --transpile-only -r tsconfig-paths/register -r dotenv-expand/config -r '@hyperdx/node-opentelemetry/build/src/tracing' ./src/tasks/index.ts", | ||
| "build": "rimraf ./build && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && cp -r ./src/opamp/proto ./build/opamp/", | ||
| "build:vercel": "rimraf ./build && tsc -p tsconfig.vercel.json && tsc-alias -p tsconfig.vercel.json && cp -r ./src/opamp/proto ./build/opamp/", | ||
| "lint": "npx eslint . --ext .ts --max-warnings 302", |
…ki/exemplars-agent-surface # Conflicts: # packages/api/package.json
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 73f9156. Configure here.
| 'source — use clickstack_list_sources and pick one whose kind is ' + | ||
| '"trace"; anything else is rejected on save. Defaults to the chart ' + | ||
| "source's linked trace source when omitted.", | ||
| ), |
There was a problem hiding this comment.
Stacked-line MCP drops exemplar fields
Medium Severity
enableExemplars and exemplarTraceSourceId were added to the shared time-chart Zod schema and to the shared stacked converter, so stacked_line tiles accept and emit them on the REST path. mcpStackedLineTileSchema omits both fields, so an MCP get-then-save of a stacked-line tile that already has exemplars (the editor does not gate on display type) strips them with a 200.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 73f9156. Configure here.
| "build": "rimraf ./build && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && cp -r ./src/opamp/proto ./build/opamp/", | ||
| "build:vercel": "rimraf ./build && tsc -p tsconfig.vercel.json && tsc-alias -p tsconfig.vercel.json && cp -r ./src/opamp/proto ./build/opamp/", | ||
| "lint": "node ../../scripts/ci/oxlint-warnings.mjs --max-warnings 173 && yarn run -T oxfmt --check 'src/**/*.ts' 'scripts/**/*.ts'", | ||
| "lint": "node ../../scripts/ci/oxlint-warnings.mjs --max-warnings 174 && yarn run -T oxfmt --check 'src/**/*.ts' 'scripts/**/*.ts'", |
There was a problem hiding this comment.
Lint warning threshold raised again
Low Severity
The oxlint max-warnings cap in the lint script was raised from 173 to 174, so a newly introduced warning is absorbed by the threshold instead of being fixed. That hides the new finding from CI and makes the next warning cheaper to paper over the same way.
Reviewed by Cursor Bugbot for commit 73f9156. Configure here.


Last of the PRs replacing #2536. Stacked on #2808 — these fields do nothing without the overlay.
What it does
enableExemplarsandexemplarTraceSourceIdare accepted on line and stacked-bar tiles through the external v2 API and the MCP dashboard tools.The part that was actually broken
The fields have to survive three places, and the original change only cleared the first:
convertToInternalTileConfig'spicklist on the way in,convertToExternalTileChartConfigon the way out.They validated on write and were then dropped before persistence. So the feature could only ever be switched on by a human in the chart editor — an agent could set the field, get a 200, and have it silently vanish. The round trip is what makes them usable.
Also documented in the OpenAPI spec, which is hand-maintained JSDoc rather than generated from the zod schemas — so adding schema fields alone left the published contract silent about them.
MCP describe strings
They follow the file's own convention for source ids: say to call
clickstack_list_sourcesand pick a trace-kind source, and note that the flag only renders on an exemplar-eligible tile (single non-ratio histogram series, no groupBy). Without that an agent gets a 200 and no markers, with nothing explaining why.Verification
make ci-lintandmake ci-unit(5,350 tests) pass. Merged cleanly with main'sseriesLimitaddition, which landed in the same conversion functions — both sets of fields are kept.Note
Medium Risk
Adds dashboard save validation and conversion paths for exemplar trace references; wrong refs are rejected on write but unchanged tiles are exempt on update to avoid wedging edits.
Overview
enableExemplarsandexemplarTraceSourceIdcan now be set on line and stacked-bar dashboard tiles via the external v2 API, MCP dashboard schemas, and OpenAPI docs. The fix is that these fields round-trip through tile conversion (convertToInternalTileConfig/ external chart config output) instead of passing schema validation and being dropped before persistence.exemplarTraceSourceIdis validated as an ObjectId, must exist for the team, and must be a Trace source (same spirit as the heatmap gate). On dashboard updates, checks run only on tiles whose exemplar config actually changed—including turning exemplars on—so a stale or deleted trace source on an unchanged tile does not block unrelated edits.Unit, integration, and MCP schema tests cover round-trips, rejection cases, and PUT scoping behavior.
Reviewed by Cursor Bugbot for commit 73f9156. Bugbot is set up for automated code reviews on this repo. Configure here.