fix preserve color rules for SQL and PromQL charts - #2940
Conversation
🦋 Changeset detectedLatest commit: 2df59d1 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 |
|
@espenloov is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThe PR now preserves conditional color rules for SQL and PromQL Number tiles across editor conversion and external dashboard API round trips.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported external-representation loss is addressed on both external conversion legs and covered through create, read, and update.
|
| Filename | Overview |
|---|---|
| packages/app/src/components/ChartEditor/utils.ts | Adds colorRules to both saved and rendered SQL/PromQL config allowlists, addressing the original persistence loss. |
| packages/api/src/routers/external-api/v2/utils/dashboards.ts | Preserves and normalizes raw-SQL Number color rules in both directions of external dashboard conversion. |
| packages/api/src/utils/zod.ts | Extends the raw-SQL Number external schema with the bounded Number-tile color-rule contract. |
| packages/api/src/routers/external-api/tests/dashboards.int.test.ts | Covers create, read, update, normalization, and validation of raw-SQL Number color rules. |
| packages/app/src/components/ChartEditor/tests/utils.test.ts | Verifies SQL and PromQL color rules survive saved-config and render-config conversion. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Editor[Chart editor form] --> Conversion[SQL / PromQL config conversion]
Conversion --> Stored[(Saved dashboard)]
Stored --> ExternalGET[External API GET]
ExternalGET --> ExternalPUT[External API PUT]
ExternalPUT --> Stored
Stored --> Renderer[Number tile renderer]
Reviews (3): Last reviewed commit: "test raw SQL color rules" | Re-trigger Greptile
|
I overlooked the external dashboard conversion path and had only tested the editor round trip. I’ve now updated the external schema and both conversion directions. |
Deep ReviewConditional color rules ( ✅ No critical issues found. 🟡 P2 -- recommended
🔵 P3 nitpicks (3)
Reviewers (7): correctness, adversarial, api-contract, kieran-typescript, testing, maintainability, project-standards. Testing gaps:
|
|
Added the suggested raw SQL validation and normalization tests, and updated the stale comments. #2940 (comment) |
Summary
Conditional color rules configured for Number tiles were silently dropped when the chart used raw SQL or PromQL. The settings drawer accepted the rules and saving succeeded, but the rules disappeared after reloading the dashboard.
convertFormStateToSavedChartConfigandconvertFormStateToChartConfiguse explicitpick()allowlists for SQL and PromQL configs. WhencolorRuleswas added toSharedChartSettingsSchema, it was not added to these allowlists.This change:
colorRulesto the SQL and PromQL branches of both conversion functions.Investigation
The issue was reproduced on a self-hosted ClickStack deployment using HyperDX 2.35.0:
(promql later diagnosed after looking at the code)
The failure was then isolated as follows:
colorwas stored whilecolorRuleswas absent.RawSqlBaseChartConfigSchemaand the other chart schemas inheritcolorRulesfromSharedChartSettingsSchema.colorRulesdirectly into MongoDB and confirmed that the existing renderer applied them correctly.ChartEditor/utils.tsonmainwith the released application and confirmed that both contained the same missing allowlist entries.Validation
Test Suites: 1 passed
Tests: 90 passed
The new tests verify that
colorRulessurvive:How to test on Vercel preview
Preview routes: /dashboards
Steps:
SELECT 1, and run the query.References
PR #2386 — #2386