[pull] main from SigNoz:main - #844
Merged
Merged
Conversation
…12158) * fix(dashboardtypes): accept threshold value of 0 on create A NumberPanel/TimeSeries/Table threshold with `value: 0` (a legitimate value the SigNoz UI emits by default) was rejected on create with `dashboard_invalid_input` "Field validation for 'Value' failed on the 'required' tag". go-playground/validator's `required` treats a numeric field equal to its zero value as "missing", so `validate:"required"` on the float `Value` wrongly rejected 0. Drop `validate:"required"` from `Value` on ThresholdWithLabel and ComparisonThreshold; keep `required:"true"` since the field is always present in the schema (0 is a valid present value, not an absent one), so the OpenAPI/generated client are unaffected. `Color` keeps both tags — an empty colour is genuinely invalid. Drop the two "missing value" cases from TestValidateRequiredFields, which asserted the removed invariant. * fix(querybuildertypesv5): round-trip zero-valued query spec fields A dashboard/alert query that sets a zero-valued field — `disabled: false`, `legend: ""`, or an explicit empty `groupBy`/`order`/`selectFields`/etc. — created fine but the GET response omitted it, so a typed client that echoes what it sent (Terraform, SDKs, PUT-after-GET) read back `null`/absent and reported drift. `,omitempty` dropped these zero values on the way out. Fix the create -> GET asymmetry: - Slice fields use `,omitzero` instead of `,omitempty`. `omitzero` omits a nil slice (field never set stays absent) but keeps an explicit non-nil `[]`, so an empty array round-trips as `[]` and there is no `null` regression. Applied to groupBy, order, selectFields, aggregations, functions, secondaryAggregations and function args across the builder, formula, trace-operator and join specs, plus ListPanelSpec.selectFields. - Scalars `disabled` (bool) and `legend` (string) drop the tag entirely; `omitzero`/`omitempty` both suppress false/"", so the only way to round-trip them is to always serialize. Result types in resp.go keep `,omitempty` — they are server-computed and never round-tripped. Regenerate docs/api/openapi.yml and the frontend client: the omitzero slices are now `nullable: true` in the schema (never null on the wire, but the generated types gain `| null`, which existing consumers already handle via `?? []`). * test(dashboard): round-trip serialization for zero-valued fields Add a v2 dashboards integration test that creates one minimal dashboard (stripped from SigNoz/dashboards cicd-perses.json) and asserts the create -> GET round-trip preserves every zero-valued field the fix targets: - threshold value 0 (ComparisonThreshold + ThresholdWithLabel) is accepted on create and echoed back - builder slices set to an explicit [] (groupBy/order/selectFields/functions) round-trip as [], while a bare builder's unset slices stay absent (never null) on read - scalars disabled/legend always echo false/"" Table-driven: one equality table for round-tripped values and one absence table for omitted slices. * test(dashboard): fold round-trip test into 03_v2_dashboard Move test_dashboard_v2_roundtrip_preserves_zero_values alongside the other v2 dashboard tests (test_create_rejects_*, lifecycle, ...) instead of a standalone file, with the dashboard payload inlined per this suite's style.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )