fix(common-utils): guard metadata rollup queries against invalid date… - #2941
fix(common-utils): guard metadata rollup queries against invalid date…#2941Vansh98789 wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 65102f3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
@Vansh98789 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 prevents invalid JavaScript dates from being serialized as ClickHouse
Confidence Score: 5/5The PR appears safe to merge, with no actionable changed-code failures identified. The new guards reject non-finite date bounds before the affected metadata rollup queries construct ClickHouse integer parameters, while preserving the established return contracts used by callers.
|
| Filename | Overview |
|---|---|
| packages/common-utils/src/core/metadata.ts | Adds early validation to avoid executing metadata key and rollup key/value queries with non-finite timestamps; no changed-code defect was identified. |
| packages/common-utils/src/core/utils.ts | Adds a straightforward helper that rejects date bounds whose timestamps are not finite. |
| packages/common-utils/src/core/tests/metadata.test.ts | Covers valid and invalid date ranges and verifies that invalid getMapKeys input does not reach ClickHouse. |
| .changeset/tidy-invalid-dates.md | Correctly records the metadata-query guard as a patch-level common-utils change. |
Reviews (1): Last reviewed commit: "Merge branch 'main' into fix/invalid-dat..." | Re-trigger Greptile
Summary
Fixes
BAD_QUERY_PARAMETER(457) failures on metadata key/value rollup queries (e.g. filter dropdowns and field lists).When a metadata query is built with an invalid date in its date range,
Date.getTime()returnsNaN. ThatNaNis serialized as the literal string"nan"and bound to a ClickHouseInt64parameter, causing the query to fail with:This happens in two places in
metadata.ts:getMapKeys— builds rollup queries fromgetAlignedDateRange(dateRange, granularity)and binds{ Int64: date.getTime() }getMetadataMVKeyValues— same pattern for batched key/value lookupsChanges
common-utils/src/core/utils.tsisDateRangeValid(dateRange)— returnsfalseif either bound'sgetTime()is not a finite numbercommon-utils/src/core/metadata.tsgetMapKeys— skips metadata queries and returns[]when the date range is invalidcommon-utils/src/core/metadata.tsgetMetadataMVKeyValues— returnsundefinedso callers fall through to the raw-table strategycommon-utils/src/core/__tests__/metadata.test.tsgetMapKeysguard.changeset/tidy-invalid-dates.mdTests
isDateRangeValidaccepts a valid rangeisDateRangeValidrejects a range with an invalid start dateisDateRangeValidrejects a range with an invalid end dategetMapKeysreturns[]and never calls ClickHouse when given an invalid rangeTest command
cd packages/common-utils npx jest src/core/__tests__/metadata.test.tsScreenshots or video
N/A — non-UI change.
How to test on Vercel preview
N/A — non-UI change.
References