fix(fn-dashboard): do not mask empty panel query fields - #230
Open
GurinderRawala wants to merge 11 commits into
Open
fix(fn-dashboard): do not mask empty panel query fields#230GurinderRawala wants to merge 11 commits into
GurinderRawala wants to merge 11 commits into
Conversation
…payload Adds custom-dashboard fields to the dashboard DTO/model, wires tag-based filtering through the search store, and adds the supporting migration.
Heavier Geist-style font weights with negative heading tracking, layered low-opacity shadows, roomier panel padding/header height, white light-mode panel surfaces, and a 12px panel radius with a hover elevation transition.
Adopts @heroicons/react, the icon set used by coderabbit-ui, for the panel info icon so it matches the rest of the CodeRabbit design system.
Rounds the popover, converts quick ranges to inset pills, restyles section headers as small-caps eyebrows and recesses the footer. Also fixes the boxed outline on the active tab (caused by Tab's overflow clipping its rounded underline) and keeps select menus unclipped by dropping overflow:hidden.
Each panel header renders a pen icon when the embedding host opts in via `enablePanelEdit`. Clicking it reports the panel back through the existing `metadata.eventListener` channel, so the host owns the editing UI and Grafana only surfaces the trigger. Also sizes the embedded single-panel view from the host-measured portal container instead of `windowHeight * 0.85`, which overflowed the host box and cropped the panel.
A reporting-backed custom dashboard panel failed to render with:
[Grafana proxy]:: Failed to resolve FN-redacted query
rawSqlPrefix: '[MFE_REDACTED:p:4:A]'
`maskRawQueryFields` masked any query field whose value was a string,
including the empty string. For a panel that intentionally carries no SQL that
fabricates a `[MFE_REDACTED:p:<id>:<refId>]` marker promising the proxy a query
which does not exist. The proxy must parse a valid key out of any value with
that prefix, resolves the panel, finds an empty `rawSql`, and fails the whole
`/api/ds/query` batch closed rather than rendering the panel.
Empty query fields are now left untouched. This is safe by construction: there
is no query text to leak, and the marker's only purpose is to stand in for text
that was removed.
Two shapes depend on an intentionally empty query field:
- CodeRabbit reporting-backed panels, whose data comes from the reporting API
via a `crReportingTag` on the target rather than from SQL.
- Variable metricFindQueries, which already arrive with an empty rawSql and a
`tempVar<N>` refId; the proxy has a dedicated pass-through for these that
the fabricated marker was bypassing.
Scoped to the masking predicate rather than gated on dashboard kind: the fork
has no notion of a "custom" dashboard, and an empty query is meaningless to
mask for any dashboard.
Three regression tests cover an empty rawSql, a whitespace-only query, and a
mixed dashboard where a non-empty query on another panel is still masked.
📝 WalkthroughWalkthrough
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
Base automatically changed from
custom-dashboards
to
coderabbit_micro_frontend
August 31, 2026 14:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A reporting-backed custom dashboard panel failed to render:
Root cause
maskRawQueryFieldsmasked any query field whose value was a string — including the empty string:Verified against
simplejson:CheckGet("rawSql")on""returnsok=trueandString()returns("", nil), so an empty value took the mask branch.For a panel that intentionally carries no SQL, that fabricates a marker promising the proxy a query which does not exist. The proxy's contract is to fail closed on any value carrying the redaction prefix — it must parse a valid key rather than forward a literal placeholder upstream. So it resolves panel 4, finds
rawSql: "", hitsif (!originalSql) return null, and rejects the entire/api/ds/querybatch.Fix
Skip masking when the query field is empty or whitespace-only. Safe by construction: there is no query text to leak, and the marker exists solely to stand in for text that was removed.
Two shapes depend on an intentionally empty query field:
crReportingTagon the target rather than from SQL.rawSqland atempVar<N>refId. The proxy has a dedicated pass-through for exactly this shape (if (raw.length === 0)), which the fabricated marker was routing around. So this also removes a latent inconsistency that predates the reporting work.Why not gate on "is this a custom dashboard?"
The requested framing was to skip tag generation for custom dashboards specifically, but that isn't the right seam:
pkg/apihas nocd-prefix or dashboard-kind concept; introducing one would mean threading a classification through the mask path purely to express "this panel has no SQL" — which the panel already states by having no SQL.The narrower predicate fixes the reported failure, keeps every non-empty query masked, and adds no new coupling.
Verification
go build ./pkg/api/go test ./pkg/api/ -run "TestMask|TestIsCodeRabbitMFE|TestMfe|TestPanelAndVariable"gofmt -lThree regression tests added:
rawSqlis left untouched, and a siblingcrReportingTagsurvives intact[MFE_REDACTED:p:5:A]I confirmed the tests actually catch the bug: with the guard removed all three fail with
actual: "[MFE_REDACTED:p:4:A]"; with it restored all pass.Pre-existing failure, unrelated:
TestDashboardSnapshotAPIEndpoint_singleSnapshotpanics withno guardian factory implementation provided. I confirmed it fails identically on a stashed/clean tree.Related
Pairs with mono#25309, which generates these reporting-backed panels. Both are needed for a reporting panel to render.
Summary by CodeRabbit