Repository navigation
Conversation
The query `timezone` was only validated as a free-form string, so invalid or malformed values were accepted and handled inconsistently between the native (Tesseract) and legacy planners. Validate it against known IANA zone names so bad values are rejected early with a clear error.
|
Claude finished @ovr's task in 4m 49s —— View job Review complete — approach is sound, and it closes a real SQL injection vector. 1 medium, 4 low (4 inline comments)Full review — findings, verification notes, and task listSummaryThe fix is well-placed. Worth stating explicitly in the PR description: this is not only a consistency/UX fix. Findings
Residual gap noted inline: moment-timezone Verified, not a problem
Not verifiedCouldn't run Task list
No prior review threads existed on this PR, so nothing to resolve or dedupe against. |
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #11575 +/- ##
===========================================
- Coverage 84.05% 59.28% -24.78%
===========================================
Files 257 228 -29
Lines 81582 18200 -63382
Branches 0 3681 +3681
===========================================
- Hits 68576 10790 -57786
+ Misses 13006 6861 -6145
- Partials 0 549 +549
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Accept the query `timezone` case-insensitively and normalize it to the canonical IANA zone name in the API gateway, so downstream consumers (the generated SQL and the query response) always receive a well-formed value. Add tests covering case-insensitive acceptance and canonical normalization.
|
Claude finished @ovr's task in 3m 7s —— View job Re-review of
|
| # | Sev | Location | Issue |
|---|---|---|---|
| 1 | Medium | query.js:513-514, query.js:525, query.js:552, gateway.ts:988 |
Joi returns the coerced value in value, not by mutating the input. Three of the four call sites destructure only error, so timezoneSchema's return zone.name is dead code there — the pre-agg and jobs routes forward the raw string. Only normalizeQuery is normalized, and only because it redoes the work by hand at line 450. |
| 2 | Medium | BaseQuery.js:301, base-query.test.ts:152-176 |
BaseQuery validates but doesn't canonicalize, and the new positive test now asserts 'utc' / 'america/new_york' construct fine. For any path that skips querySchema (SQL API req.body.timezone at gateway.ts:483, scheduled refresh, and the pre-agg routes from #1) those values reach Tesseract and fail at parse::<Tz>() (query_tools.rs:61, chrono-tz 0.8.2 is case-sensitive) while the legacy planner accepts them. The test enshrines the divergence rather than closing it. |
| 3 | Low | query.js:59-67 |
Normalizing rewrites deprecated aliases to canonical names (Europe/Kiev→Europe/Kyiv, Asia/Calcutta→Asia/Kolkata, US/Eastern→America/New_York). Since timezone feeds pre-aggregation partition/version keys, affected tenants get a pre-agg rebuild on upgrade. Fine as a decision — needs to be a documented behavior change, not a surprise. |
| 4 | Low | query.js:61 |
helpers.error('any.invalid') still renders as "timezone" contains an invalid value — names neither the offending value nor the expected format. Worse in the array cases ("timezones[0]" ...). |
| 5 | Low | query.js:428 |
CUBEJS_DEFAULT_TIMEZONE is folded into query.timezone before querySchema.validate, so a misconfigured env var now surfaces on every query as Invalid query format: ..., pointing the operator at their payload when the fault is server config. Validate the env once at startup, or use a distinct message. (Line not in the diff, so not postable inline.) |
| 6 | Low | base-query.test.ts |
Still no quote-carrying entry in the negative list, so the injection vector into AT TIME ZONE '${this.timezone}' has no regression test; still a for loop rather than it.each, so a failure doesn't say which input broke. |
The cheapest fix for #1 + #2 together is to drop the normalization from Joi (validate only) and canonicalize once in the BaseQuery constructor — this.timezone = zone.name. That's the single choke point every path already passes through, and it makes query.js:450 unnecessary.
Verified, not a problem
- Security fix still intact —
this.timezoneis interpolated raw into SQL string literals across most dialects (PostgresQuery.ts:28,ClickHouseQuery.ts:50,SnowflakeQuery.ts:38,BigqueryQuery.ts:45,HiveQuery.ts:30,TrinoQuery.ts:7,VerticaQuery.ts:16,MysqlQuery.ts:49). TheBaseQueryguard closes that on every path regardless of the normalization gaps above. Worth stating in the PR description/changelog — it affects how this gets backported. - Dependencies / imports —
moment-timezoneis already a direct dep of both packages;BaseQuery.js:11already imported it, and themoment→moment-timezoneswap inquery.js:2is safe (moment-timezone re-exports moment, somoment.utc/moment.HTML5_FMTstill resolve). moment.tz.zone(...)?.nameat line 450 — optional chaining is already used elsewhere in this file and the package's babel config handles it.timezoneSchema.required()— Joi schemas are immutable, so deriving the required variant forqueryPreAggregationPreviewSchemadoesn't leakrequiredinto the shared schema.- Perf — one hashed zone lookup per query plus a one-time lazy unpack; negligible.
- Docs —
docs-mintlify/reference/core-data-apis/rest-api/query-format.mdx:45-47documentstimezoneas a TZ Database Name, so validation matches the documented contract.
Not verified
- Could not execute
nodeoryarn testin this checkout (dependencies not installed / command not permitted), so the moment-timezone alias behavior in finding ResultSet pivot methods documentation #3 comes from readingaddLink/getZonerather than an empirical check — worth a 10-secondnode -econfirmation before writing it into release notes. The test changes were reviewed by reading only; CI is the source of truth for pass/fail.
Task list
- Diff
origin/master...HEADand identify what the new commit changed - Trace whether Joi's normalized value actually reaches consumers on each route
- Re-check
BaseQueryguard against the Rustparse::<Tz>()semantics (chrono-tz 0.8.2) - Assess the pre-agg cache-key implications of canonicalization
- Re-assess test coverage against the new behavior
- Dedupe against prior threads; resolve stale ones
- Post inline comments and summary
Resolved one of my own now-addressed threads (the query.js:67 "canonicalize instead of existence-check" comment — the fix direction was taken). Left the BaseQuery.js:303 and base-query.test.ts:176 threads unresolved: both concerns still apply, and the new inline comments extend them with what the latest commit changed. No human-authored threads touched.
Re-review of
|
| # | Sev | Location | Issue |
|---|---|---|---|
| 1 | Medium | query.js:72 |
helpers.message() is called with a bare string; joi expects a messages object keyed by error code. The sibling validator added in this same PR uses the correct form (optionsValidate.ts:9), as does the existing CubeValidator.ts:392 — this is the only bare-string call in the repo. joi resolves messages['custom'] to undefined and falls back to its "error code is not defined" placeholder, so the intended message is likely never shown. No test asserts the message body on this route (only /Invalid query format/), so CI won't catch it. Also, both validators interpolate the user value into the template source — timezone: "{{#label}}" echoes the label and an unbalanced { can throw during error rendering (400 → 500); pass it as a local ({ tz: value }) instead. |
| 2 | Medium | optionsValidate.ts:9, OptsHandler.ts:92/:417 |
optionsValidate(opts) runs on user-supplied options only, while the env default is merged after — so CUBEJS_SCHEDULED_REFRESH_TIMEZONES (env.ts:273, plain split(',')) bypasses the new schema entirely. The Joi.func() alternative is likewise unchecked (server.ts:797). And the custom validates without canonicalizing (and optionsValidate discards Joi's value), so ['utc'] passes and is forwarded verbatim → RefreshScheduler → BaseQuery → Tesseract parse::<Tz>() failure while the legacy planner accepts it. Scheduled refresh is now the one route where the divergence this PR targets still exists. |
| 3 | Low | BaseQuery.js:301 (existing thread) |
BaseQuery still validates without canonicalizing, and base-query.test.ts:150-160 now asserts 'utc'/'america/new_york' construct fine on the strength of a comment saying normalization "happens at the API gateway input layer". True for the gateway routes after this commit — not for scheduled refresh (#2) or direct BaseQuery consumers. this.timezone = zone.name in the constructor makes the assertion true and collapses #2's second half at the same time. |
| 4 | Low | changelog / docs (existing thread) | Canonicalization rewrites deprecated aliases (Europe/Kiev→Europe/Kyiv, Asia/Calcutta→Asia/Kolkata, US/Eastern→America/New_York). Since timezone feeds pre-agg partition/version keys, affected tenants get a rebuild on upgrade. Fine as a decision — should be an explicit release-note line. Same for previously-tolerated values like +05:00 now hard-failing. |
| 5 | Low | base-query.test.ts |
Negative list is 'Not/AZone', '+05:00', '+05', '05', 'foo/bar' — still no quote-bearing entry, so the actual injection vector into AT TIME ZONE '${this.timezone}' (PostgresQuery.ts:28) has no regression test. One entry like "UTC' AT TIME ZONE 'UTC" would pin it. |
Verified, not a problem
valuevs raw at the new call sites —preAggsJobsRequestSchemaand the pre-agg schemas are plainJoi.object().keys(...)withoutstripUnknown/unknown(true), so unknown keys error rather than being silently dropped; switching tovalue.selector/value.timezonesdoesn't lose fields.normalizeTimezoneon/v1/cubesql— throws inside the existingtry, so it routes throughhandleErrorand becomes a 400 rather than an unhandled rejection. Empty/undefined passthrough is correct and tested (the SQL API supplies its own default downstream).normalizeQueryPreAggregationPreview—{ ...query, timezone: value.timezone }is safe;timezoneisrequired()on that schema sovalue.timezoneis always populated.- New
moment-timezonedep incubejs-server-core—^0.5.46already exists as a resolved range in the workspace (cubejs-api-gatewayuses the identical range), so no lockfile churn. Ranges differ across packages (0.5.46/0.5.47/0.5.48) but that predates this PR. - Security fix intact —
this.timezoneis still interpolated raw into SQL string literals (PostgresQuery.ts:28,ClickHouseQuery.ts:50,SnowflakeQuery.ts:38,BigqueryQuery.ts:45,HiveQuery.ts:30,TrinoQuery.ts:7,VerticaQuery.ts:16,MysqlQuery.ts:49); theBaseQueryguard closes that on every path. Still worth stating in the PR description — it affects backport handling. - tzdb skew — moment-timezone here is much newer than chrono-tz
0.8.2(cubesqlplanner/Cargo.toml:20), so recently-added zone names pass JS validation and fail in the native planner. Follow-up, not a blocker.
Not verified
node_modules is not installed in this checkout and I couldn't install joi, so finding #1 rests on reading joi's error-template resolution plus the repo's own precedent (CubeValidator.ts:392, optionsValidate.ts:9) rather than an empirical run. A 10-second check — assert the thrown message in normalize-query.test.ts — settles it either way, and is worth having as a test regardless. Test suites were reviewed by reading only; CI is the source of truth for pass/fail.
Thread housekeeping
Resolved two of my own now-addressed threads: the query.js:540 "normalized value discarded at three call sites" thread (all four sites now use value) and the base-query.test.ts "for-loop / no positive assertion" thread (converted to it.each, SQL assertion added). Left unresolved: BaseQuery.js:303 (canonicalization, finding #3), the query.js alias/changelog thread (finding #4), and the base-query.test.ts positive-block thread (findings #3/#5) — all still apply. No human-authored threads touched.
Task list
- Diff
47516ce..HEADand identify what the new commit changed - Re-verify each prior finding against the current code
- Trace the env-var / function paths for
scheduledRefreshTimeZones - Check
valuevs raw semantics at the switched call sites (unknown-key stripping) - Check
helpers.messageusage against repo precedent - Verify the new
moment-timezonedependency needs no lockfile change - Resolve stale threads, dedupe new comments
- Post inline comments and summary
View job run · branch hanoi
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Re-review of
|
| # | Sev | Location | Issue |
|---|---|---|---|
| 1 | Medium | optionsValidate.ts:9, OptsHandler.ts:92/:417 |
Existing thread, still open. optionsValidate(opts) sees user-supplied options only; scheduledRefreshTimeZones: getEnv('scheduledRefreshTimezones') is merged as a default after, so CUBEJS_SCHEDULED_REFRESH_TIMEZONES (env.ts:273, plain split(',')) bypasses the new schema — as does the Joi.func() alternative (server.ts:797). And the custom validates without canonicalizing while optionsValidate discards joi's value, so ['utc'] is forwarded verbatim → RefreshScheduler → BaseQuery → Tesseract parse::<Tz>() failure, legacy planner accepts. Scheduled refresh remains the one route where the divergence this PR targets survives. |
| 2 | Low | optionsValidate.ts:9 (new) |
The { tz: value } treatment landed in query.js but not in the sibling validator, which still interpolates ${value} into the template source. Same message-fidelity / template-parse exposure the query.js fix just closed. |
| 3 | Low | BaseQuery.js:301 (existing thread) |
Still validates without canonicalizing, and base-query.test.ts:150-161 asserts 'utc'/'america/new_york' construct fine on the strength of a comment saying normalization happens "at the API gateway input layer" — true for the gateway routes after 6141a98, not for scheduled refresh (#1) or direct BaseQuery consumers. this.timezone = zone.name makes the assertion true and collapses half of #1 at the same time. (The message-colon nit in that thread is fixed — it now reads Incorrect timezone ${tz}, matching the Rust side.) |
| 4 | Low | query.js:455 (new) |
CUBEJS_DEFAULT_TIMEZONE is folded into query.timezone before querySchema.validate, so a misconfigured env var now surfaces on every request as Invalid query format: "timezone" must be a valid IANA time zone… — accurate about what is wrong, misleading about whose input caused it. normalizeTimezone at startup would fail fast instead. |
| 5 | Low | changelog + base-query.test.ts (existing threads) |
(a) Canonicalization rewrites deprecated aliases (Europe/Kiev→Europe/Kyiv, Asia/Calcutta→Asia/Kolkata, US/Eastern→America/New_York); since timezone feeds pre-agg partition/version keys, affected tenants get a rebuild on upgrade — needs an explicit release-note line, along with previously-tolerated values like +05:00 now hard-failing. (b) The negative list still has no quote-bearing entry, so the injection vector into AT TIME ZONE '${this.timezone}' (PostgresQuery.ts:28) has no regression test; one case like "UTC' AT TIME ZONE 'UTC" would pin it. |
Verified, not a problem
helpers.message(messages, local)— two-argument form is the documented joi 17 signature for custom methods, and{{#tz}}is the correct local-context reference (#prefix). Matches the repo's own precedent atCubeValidator.ts:392.- All four joi call sites consume
value—query.js:474,:559,:585,gateway.ts:1000. None of these schemas usestripUnknown/unknown(true), so unknown keys error rather than being silently dropped; switching from raw tovalueloses nothing.normalizeQueryPreAggregationPreview's{ ...query, timezone: value.timezone }is safe because that field isrequired(). - Security fix intact —
this.timezonestill reaches SQL string literals raw across dialects (PostgresQuery.ts:28,ClickHouseQuery.ts:50,SnowflakeQuery.ts:38,BigqueryQuery.ts:45,HiveQuery.ts:30,TrinoQuery.ts:7,VerticaQuery.ts:16,MysqlQuery.ts:49); theBaseQueryguard closes that on every path. Still worth stating in the PR description — it affects how this gets backported. - Coverage —
normalizeQuery,normalizeQueryPreAggregations,normalizeQueryPreAggregationPreview,normalizeTimezoneandoptionsValidateall have tests including empty-value passthrough, andbase-query.test.ts:163now asserts the renderedAT TIME ZONE 'America/New_York'. One gap: the joi-route tests assert only/Invalid query format/, never the rendered message body, so the fix in this commit has no direct regression test — the only assertion on the text (normalize-query.test.ts:105) covers the non-joinormalizeTimezonepath. - tzdb skew — moment-timezone is much newer than chrono-tz
0.8.2(cubesqlplanner/Cargo.toml:20), so recently-added zone names pass JS validation and fail in the native planner. Follow-up, not a blocker.
Not verified
node_modules is not installed here and running node wasn't permitted, so the joi template-resolution reasoning in #2 and the alias list in #5(a) come from reading joi's template compiler and moment-timezone's addLink/getZone rather than an empirical check. Both are worth a 10-second node -e confirmation before the alias behavior goes into release notes. Test suites were reviewed by reading only; CI is the source of truth for pass/fail.
Thread housekeeping
Nothing to resolve this round — all four unresolved claude threads still have live concerns (BaseQuery.js:303, the query.js alias/changelog thread, the base-query.test.ts positive-block thread, and optionsValidate.ts:9). Re-affirmed rather than re-posted; the unresolved state already communicates that. The bare-string helpers.message thread was addressed by this commit and is already resolved. No human-authored threads touched.
Task list
- Diff
6141a98..HEADand identify what changed - Verify the
helpers.message({ custom }, { tz })form against joi's API and repo precedent - Re-check each prior finding against current code
- Confirm all joi call sites consume the normalized
value - Check test coverage for the message body specifically
- List review threads, dedupe, resolve stale ones (none stale)
- Post inline comments and summary
View job run · branch hanoi
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
I'll analyze this and get back to you. |
The route validated only the timezone and read the remaining fields straight off req.body. Describe the body with a Joi schema instead, covering query, timezone, cache and throwContinueWait, and pass the validated value to execSql. Follows how the other routes validate their input, and gives the next field added here a place to be declared. A missing query and unknown fields or cache modes are now rejected with "Invalid query format" instead of reaching the native side. Also reuse one cache-mode schema for querySchema.cacheMode/cache and this route.
|
Claude finished @ovr's task in 3m 22s —— View job Re-review of
|
| # | Sev | Location | Issue |
|---|---|---|---|
| 1 | Low | gateway.ts:484 (new inline) |
Three edges: (a) Joi.object() without .required() accepts undefined, so an absent req.body passes validation and body.query throws a TypeError → 500 instead of 400 — unreachable today (line 474 destructures req.body first, express.json() always sets an object) but one token to close; (b) unknown keys are now a hard 400 for the whole request, which is a version-skew break worth a release note — a newer client sending a field an older gateway doesn't declare fails the entire query, and cacheMode (accepted by querySchema, not here) goes from silently-ignored to 400; (c) null/'' timezones used to be forwarded as unset and now 400 — deliberate, but JSON clients that serialize absent optional fields as null will start failing. |
| 2 | Low | test/index.test.ts:1322-1500 |
No route-level negative test. The new normalize-query.test.ts block exercises cubeSqlRequestSchema in isolation, so nothing pins the wiring (UserError → handleError → 400) or the response body. One supertest case with timezone: 'Not/AZone' expecting 400 + /valid IANA time zone/, and one with {} expecting "query" is required, would cover it. |
| 3 | Low | optionsValidate.ts:108, server.ts:797 |
The Joi.func() alternative for scheduledRefreshTimeZones remains unvalidated — its awaited result goes straight into queryingOptions.timezones. With the env var canonicalizing at the source and the array form canonicalizing in validateOptions, the function form is the last route where the cross-planner divergence survives: a config returning ['utc'] fails Tesseract's case-sensitive parse::<Tz>() (query_tools.rs:61) while the legacy planner accepts it. A canonicalTimezone pass over the resolved list closes it. |
| 4 | Low | BaseQuery.js:307 |
Still truthiness-gated (this.timezone && (typeof … !== 'string' || !canonicalTimezone(…))), so a falsy non-string — 0, false, NaN — skips validation and reaches the dialect's AT TIME ZONE '${this.timezone}' sink. No quote, so not injection, but a DB error rather than a UserError. The gateway half is closed by Joi.string(); this is the queryRewrite / refresh-scheduler path. Gating on !== undefined && !== null && !== '' closes it. |
| 5 | Low | docs | (a) environment-variables.mdx:1409-1419 — re-checked, still no <Warning> under CUBEJS_SCHEDULED_REFRESH_TIMEZONES while CUBEJS_DEFAULT_TIMEZONE has one, though it now also fails the boot on an invalid zone, rejects +05:00, and ignores empty entries from trailing commas. (b) rest-api/reference.mdx:409-413 lists query/timezone/cache but not throwContinueWait — now that the schema is a closed list, that's a documented-vs-accepted mismatch. Fix (a) → |
| 6 | Low | base-query.test.ts:139-146, timezone.test.ts:28-40 |
Neither negative list has a quote-bearing entry, so the injection vector into AT TIME ZONE '${this.timezone}' (PostgresQuery.ts:28) — the thing this PR is really protecting — still has no regression test. One case like "UTC' AT TIME ZONE 'UTC" would pin it. (Author resolved this thread earlier; noted once more, your call.) |
Nit: cacheModeSchema is Joi.any().valid(...) rather than Joi.string().valid(...), so a non-string gets must be one of [...] rather than must be a string — harmless, just slightly less precise than the sibling fields.
Verified, not a problem
timezoneSchemaun-export — no consumer outsidequery.jsimported it (greppedpackages/*/srcandpackages/*/test); it was exported one commit ago and never released, so this isn't a breaking change to@cubejs-backend/api-gateway's surface.cacheModeSchemareuse — joi schemas are immutable, and the extracted value list is character-identical to both inlined copies it replaces, soquerySchema.cache/cacheModebehavior is unchanged.throwContinueWait: Joi.boolean()— with joi's defaultconvert: true,'true'/'false'strings now become booleans before reachingexecSql(sql-server.ts:79declaresthrowContinueWait?: boolean), so'false'no longer arrives as a truthy string. Strictly better.query: Joi.string().required()—Joi.string()doesn't coerce numbers, and rejects''by default, so both now 400 instead of reaching the native side. Matches the commit message.- Error routing — the
throwis still inside the existingtry, so it goes throughhandleErroras a 400;handleError'squery: { sql: query }still reads the pre-validationqueryfrom line 474, which is fine (it's for logging). - Security fix intact —
this.timezonestill reaches SQL string literals raw across dialects (PostgresQuery.ts:28,ClickHouseQuery.ts:50,SnowflakeQuery.ts:38,BigqueryQuery.ts:45,HiveQuery.ts:30,TrinoQuery.ts:7,VerticaQuery.ts:16,MysqlQuery.ts:49); theBaseQueryconstructor guard closes it on every path. Still worth one line in the PR description — it affects how this gets backported. - tzdb skew — moment-timezone here is much newer than chrono-tz
0.8.2(cubesqlplanner/Cargo.toml:20), so recently-added zone names pass JS validation and fail in the native planner. Follow-up, not a blocker.
Not verified
node_modules isn't installed in this checkout, so I couldn't run yarn tsc or the suites; the joi semantics above (object-without-required accepting undefined, Joi.string() not coercing, convert on booleans) come from reading joi 17 rather than an empirical run, and the client-side field lists come from reading HttpTransport.request/requestStream. CI is the source of truth for pass/fail.
Thread housekeeping
Resolved the one open thread (gateway.ts, the errors: { label: false } empty-subject message) — this commit deletes that call entirely and object validation gives the message a proper label. Its other two halves (no route-level 400 test, null/'' compat) are carried forward as findings #1/#2 in a new comment on the current line rather than left on an outdated diff. All 15 other prior claude threads were already resolved. Findings #3-#6 aren't on diff lines, so they're written out above. No human-authored threads touched.
Task list
- Diff
c08ded8..35f969fand identify what changed - Trace every
/v1/cubesqlclient (cubeSql,cubeSqlStream,HttpTransport, smoke tests) against the closed key list - Check
execSql's signature vs the coerced values now passed - Check whether un-exporting
timezoneSchemabreaks any consumer - Look for route-level negative coverage
- Re-verify each remaining open finding against the current tree
- List review threads, resolve stale ones, dedupe
- Post inline comment and summary
canonicalTimezone relied on moment.tz.zone() happening to return null for an empty string. Treat '' as unset next to undefined/null instead, so the null result is the function's own contract rather than a moment implementation detail. Behaviour is unchanged.
|
Claude finished @ovr's task in 1m 28s —— View job Re-review of
|
| # | Sev | Location | Issue |
|---|---|---|---|
| 1 | Low | gateway.ts:484 (open thread) |
Three edges on the new body schema, re-verified against the current code: (a) Joi.object() without .required() accepts undefined, so an absent req.body would pass and body.query would throw a TypeError → 500 instead of 400 — unreachable today (line 474 destructures req.body, express.json() always sets an object) but one token to close; (b) unknown keys are now a hard 400 for the whole request — right default, but a version-skew break worth a release note, and cacheMode (accepted by querySchema, not here) goes from silently-ignored to 400; (c) null/'' timezones used to be forwarded as unset and now 400 — deliberate, but JSON clients that serialize absent optional fields as null will start failing. Still no route-level negative test either: test/index.test.ts:1322-1500 is happy-path only, and the schema tests exercise cubeSqlRequestSchema in isolation, so nothing pins the UserError → handleError → 400 wiring. |
| 2 | Low | BaseQuery.js:307 |
Still truthiness-gated (this.timezone && (typeof … !== 'string' || !canonicalTimezone(…))), so a falsy non-string — 0, false, NaN — skips validation and reaches the dialect's AT TIME ZONE '${this.timezone}' sink. No quote, so not injection, but a DB error rather than a UserError. Note the irony with this commit: canonicalTimezone itself now documents in a comment why !value is the wrong gate, and timezone.test.ts pins 0/false as throwing — but this caller's !value-shaped guard is the one place that keeps those values from ever reaching it. Gating on !== undefined && !== null && !== '' closes it. |
| 3 | Low | optionsValidate.ts:108, server.ts:797 |
Re-verified: scheduledRefreshTimeZones is Joi.alternatives().try(Joi.array().items(timezoneSchema), Joi.func()) — the Joi.func() branch is unvalidated, and await this.scheduledRefreshTimeZones(context) goes straight into queryingOptions.timezones at server.ts:799. With the env var canonicalizing at the source and the array form canonicalizing in validateOptions, the function form is the last route where the cross-planner divergence survives: a config returning ['utc'] fails Tesseract's case-sensitive parse::<Tz>() (query_tools.rs:61) while the legacy planner accepts it. A canonicalTimezone pass over the resolved list closes it. |
| 4 | Low | environment-variables.mdx:1409-1419 |
Confirmed still absent: the CUBEJS_SCHEDULED_REFRESH_TIMEZONES section is four lines plus a table, no <Warning>, while CUBEJS_DEFAULT_TIMEZONE has one. This var now also fails the boot on an invalid zone, also rejects +05:00, and (since 062b0e7) ignores empty entries from trailing/repeated commas — three documentable behaviors, zero doc lines. Fix this → |
| 5 | Low | timezone.test.ts:28-38, base-query.test.ts:140-146 |
Re-read both negative lists — 'Not/AZone', 'Europ/Berlin', 'foo/bar', '+05:00', '+05', '05', the untrimmed variants — still no quote-bearing entry, so the injection vector into AT TIME ZONE '${this.timezone}' (PostgresQuery.ts:28) — the thing this PR is really protecting — has no regression test. One case like "UTC' AT TIME ZONE 'UTC" would pin it. (Author resolved this thread earlier; noted once more, your call.) |
Verified, not a problem
''reclassification is behavior-identical — the value was already returningnullviamoment.tz.zone(''); only the reason changed. Both callers treatnullthe same way (timezoneSchema→ validation message,BaseQuerynever reaches it because''is falsy), so nothing downstream shifts.- Check ordering —
''is tested beforetypeof, which is fine since''is a string; no non-string can take the early return. - Doc comment matches behavior —
@throws {TypeError} when value is neither a string nor unsetstill holds, and the summary line was updated to mention "empty" in step with the code. TypeErrorstill unreachable fromsrc— the two joi customs sit behindJoi.string()(joi 17's string type doesn't coerce numbers or booleans, andcustomruns after base validation), bothenv.tsreaders always hold strings, andBaseQuerypre-checks the type. No route that produced a 400 now produces a 500.- Security fix intact —
this.timezonestill reaches SQL string literals raw across dialects (PostgresQuery.ts:28,ClickHouseQuery.ts:50,SnowflakeQuery.ts:38,BigqueryQuery.ts:45,HiveQuery.ts:30,TrinoQuery.ts:7,VerticaQuery.ts:16,MysqlQuery.ts:49); theBaseQueryconstructor guard closes it on every path. Still worth one line in the PR description — it affects how this gets backported. - tzdb skew — moment-timezone here is much newer than chrono-tz
0.8.2(cubesqlplanner/Cargo.toml:20), so recently-added zone names pass JS validation and fail in the native planner. Follow-up, not a blocker.
Not verified
node_modules isn't installed in this checkout, so I couldn't run yarn tsc or the suites; the moment.tz.zone('') equivalence claim comes from reading normalizeName/getZone rather than an empirical run — the reclassified test case is exactly what confirms it, so CI is the source of truth for pass/fail.
Thread housekeeping
Listed all 17 threads: 16 already resolved, 1 open (gateway.ts:484, finding #1). It still applies verbatim to the current code — this commit didn't touch that file — so I left it unresolved rather than re-posting. No new inline comments this pass, since nothing in eef56da introduces a new issue. Findings #3 and #4 aren't on diff lines and #5's thread was resolved by the author, so those are written out above. No human-authored threads touched.
Task list
- Diff
35f969f..eef56daand identify what changed - Confirm the
''reclassification is behavior-preserving and check ordering vs thetypeofguard - Re-verify each remaining open finding against the current tree (
BaseQuery.js,optionsValidate.ts,server.ts, the mdx section, both negative test lists) - List review threads, resolve stale ones (none stale), dedupe
- Post summary
An empty string is not an unset value, and no caller passes one: Joi rejects it before the timezone validators run, the env accessors filter empty entries out and fall back to UTC, and the BaseQuery guard short-circuits on a falsy timezone. So treat it as a bad argument and throw, rather than reporting it as an unknown zone.
|
Claude finished @ovr's task in 2m 29s —— View job Re-review of
|
| # | Sev | Location | Issue |
|---|---|---|---|
| 1 | Low | timezone.ts:17-19 (new inline) |
'' reclassified as a TypeError. Unreachable today, but only because all four callers filter it first; .allow('') on either joi schema would make it a 500 where the old contract gave a 400. Also a poor fit for the "call-site bug" bucket, and the removed comment's durable point (!value is not a valid unset check, it swallows the non-strings that must throw) is worth keeping. |
| 2 | Low | gateway.ts:484 (open thread) |
Unchanged by this commit. (a) Joi.object() without .required() accepts undefined, so an absent req.body would pass and body.query would throw a TypeError → 500 — unreachable today (line 474 destructures req.body, express.json() always sets an object) but one token to close; (b) unknown keys are now a hard 400 for the whole request — right default, but a version-skew break worth a release note, and cacheMode (accepted by querySchema, not here) goes from silently-ignored to 400; (c) null/'' timezones used to be forwarded as unset and now 400. Still no route-level negative test: test/index.test.ts:1322-1500 is happy-path only, and the schema tests exercise cubeSqlRequestSchema in isolation, so nothing pins the UserError → handleError → 400 wiring. |
| 3 | Low | BaseQuery.js:307 |
Still truthiness-gated (this.timezone && (typeof … !== 'string' || !canonicalTimezone(…))), so a falsy non-string — 0, false, NaN — skips validation and reaches the dialect's AT TIME ZONE '${this.timezone}' sink. No quote, so not injection, but a DB error rather than a UserError. Gateway routes are covered by Joi.string(); this is the queryRewrite / refresh-scheduler path. Note this guard is also what keeps '' from reaching the helper's new throw, so the two are now coupled: gating on !== undefined && !== null && !== '' closes the falsy-non-string hole and keeps '' out. |
| 4 | Low | optionsValidate.ts:108, server.ts:797 |
Re-verified: scheduledRefreshTimeZones is Joi.alternatives().try(Joi.array().items(timezoneSchema), Joi.func()) — the Joi.func() branch is unvalidated, and its awaited result goes straight into queryingOptions.timezones. With the env var canonicalizing at the source and the array form canonicalizing in validateOptions, the function form is the last route where the cross-planner divergence survives: a config returning ['utc'] fails Tesseract's case-sensitive parse::<Tz>() (query_tools.rs:61) while the legacy planner accepts it. A canonicalTimezone pass over the resolved list closes it. |
| 5 | Low | environment-variables.mdx:1409-1419 |
Re-read it: the CUBEJS_SCHEDULED_REFRESH_TIMEZONES section is four lines plus a table, still no <Warning>, while CUBEJS_DEFAULT_TIMEZONE has one. This var now also fails the boot on an invalid zone, also rejects +05:00, and (since 062b0e7) ignores empty entries from trailing/repeated commas — three documentable behaviors, zero doc lines. Fix this → |
| 6 | Low | timezone.test.ts:28-40, base-query.test.ts:140-146 |
Neither negative list has a quote-bearing entry, so the injection vector into AT TIME ZONE '${this.timezone}' (PostgresQuery.ts:28) — the thing this PR is really protecting — has no regression test. One case like "UTC' AT TIME ZONE 'UTC" would pin it. (Author resolved this thread earlier; noted once more, your call.) |
Verified, not a problem
- Every
canonicalTimezonecaller enumerated (query.js:63,optionsValidate.ts:6,env.ts:281,env.ts:357,BaseQuery.js:307) — none can pass''today, so the new throw is unreachable frompackages/*/src. - Check ordering —
typeofbefore the''test, and''is a string either way, so the two branches can't shadow each other. - Doc comment matches behavior — the summary line and
@throwswere both updated in step with the code. - Test coverage of the reclassification — the
''case moved to its owntoThrow(TypeError)test rather than being dropped, and the non-string block still pins0/false, so the falsy cases stay covered. - Security fix intact —
this.timezonestill reaches SQL string literals raw across dialects (PostgresQuery.ts:28,ClickHouseQuery.ts:50,SnowflakeQuery.ts:38,BigqueryQuery.ts:45,HiveQuery.ts:30,TrinoQuery.ts:7,VerticaQuery.ts:16,MysqlQuery.ts:49); theBaseQueryconstructor guard closes it on every path. Still worth one line in the PR description — it affects how this gets backported. - tzdb skew — moment-timezone here is much newer than chrono-tz
0.8.2(cubesqlplanner/Cargo.toml:20), so recently-added zone names pass JS validation and fail in the native planner. Follow-up, not a blocker.
Not verified
node_modules isn't installed in this checkout (confirmed — no node_modules at the root or in cubejs-backend-shared), so I couldn't run yarn tsc or the suites. Joi.string()'s default string.empty rejection — which the reachability argument above rests on — comes from reading joi 17 rather than an empirical run. CI is the source of truth for pass/fail.
Thread housekeeping
Listed all 16 threads: 15 already resolved, 1 open (gateway.ts, finding #2). It still applies verbatim — this commit didn't touch that file — so I left it unresolved rather than re-posting. Posted one new inline comment (#1, a different file and line, no overlap with the open thread). Findings #4 and #5 aren't on diff lines and #6's thread was resolved by the author, so those are written out above. No human-authored threads touched.
Task list
- Diff
eef56da..3393f95and identify what changed - Verify the "no caller passes
''" claim against all five call sites - Check the interaction with the
.allow('')compat option suggested on the open thread - Re-verify each remaining open finding against the current tree
- List review threads, resolve stale ones (none stale), dedupe
- Post inline comment and summary
Drop the halves of the timezone comments that repeat what the assertion, the test name or the guard below already says, keeping only the part that explains why.
|
Claude finished @ovr's task in 1m 37s —— View job Re-review of
|
| # | Sev | Location | Issue |
|---|---|---|---|
| 1 | Low | gateway.ts:484 (open thread) |
(a) Joi.object() without .required() accepts undefined, so an absent req.body would pass and body.query would throw a TypeError → 500 instead of 400 — unreachable today (line 474 destructures req.body, express.json() always sets an object) but one token to close; (b) unknown keys are now a hard 400 for the whole request — right default, but a version-skew break worth a release note, and cacheMode (accepted by querySchema, not here) goes from silently-ignored to 400; (c) null/'' timezones used to be forwarded as unset and now 400. Still no route-level negative test: test/index.test.ts:1322-1500 is happy-path only, and the schema tests exercise cubeSqlRequestSchema in isolation, so nothing pins the UserError → handleError → 400 wiring. |
| 2 | Low | timezone.ts:19 (open thread) |
'' is classified as a TypeError ("call-site bug") rather than returning null. Unreachable today — re-confirmed all four callers filter it first (Joi.string()'s string.empty at query.js:62 and optionsValidate.ts:5, .filter(Boolean) at env.ts:275-278, ` |
| 3 | Low | BaseQuery.js:307 |
Still truthiness-gated (this.timezone && (typeof … !== 'string' || !canonicalTimezone(…))), so a falsy non-string — 0, false, NaN — skips validation and reaches the dialect's AT TIME ZONE '${this.timezone}' sink. No quote, so not injection, but a DB error rather than a UserError. Gateway routes are covered by Joi.string(); this is the queryRewrite / refresh-scheduler path. Gating on !== undefined && !== null && !== '' closes it, and would also keep '' away from #2's throw. |
| 4 | Low | optionsValidate.ts:108-111, server.ts:797-799 |
Re-read both: scheduledRefreshTimeZones is Joi.alternatives().try(Joi.array().items(timezoneSchema), Joi.func()) — the Joi.func() branch is unvalidated, and await this.scheduledRefreshTimeZones(context) lands straight in queryingOptions.timezones at server.ts:799. With the env var canonicalizing at the source and the array form canonicalizing in validateOptions, the function form is the last route where the cross-planner divergence survives: a config returning ['utc'] fails Tesseract's case-sensitive parse::<Tz>() (query_tools.rs:61) while the legacy planner accepts it. A canonicalTimezone pass over the resolved list closes it. |
| 5 | Low | environment-variables.mdx:1409-1419 |
Re-read the section: four lines plus a table, still no <Warning>, while CUBEJS_DEFAULT_TIMEZONE has one. This var now also fails the boot on an invalid zone, also rejects +05:00, and (since 062b0e7) ignores empty entries from trailing/repeated commas — three documentable behaviors, zero doc lines. Fix this → |
| 6 | Low | timezone.test.ts:28-40, base-query.test.ts:140-146 |
Neither negative list has a quote-bearing entry, so the injection vector into AT TIME ZONE '${this.timezone}' (PostgresQuery.ts:28) — the thing this PR is really protecting — has no regression test. One case like "UTC' AT TIME ZONE 'UTC" would pin it. (Author resolved this thread earlier; noted once more, your call.) |
Verified, not a problem
- The commit is genuinely comment-only — the diff touches no expressions, no test cases, no assertions;
BaseQuery.js's guard,canonicalTimezone's branches and both test bodies are byte-identical. canonicalTimezonecontract unchanged — re-readtimezone.ts:undefined/null→null, non-string →TypeError,''→TypeError, otherwisemoment.tz.zone()?.name. The doc comment still matches.- Security fix intact —
this.timezonestill reaches SQL string literals raw across dialects (PostgresQuery.ts:28,ClickHouseQuery.ts:50,SnowflakeQuery.ts:38,BigqueryQuery.ts:45,HiveQuery.ts:30,TrinoQuery.ts:7,VerticaQuery.ts:16,MysqlQuery.ts:49); theBaseQueryconstructor guard closes it on every path. Still worth one line in the PR description — it affects how this gets backported. - tzdb skew — moment-timezone here is much newer than chrono-tz
0.8.2(cubesqlplanner/Cargo.toml:20), so recently-added zone names pass JS validation and fail in the native planner. Follow-up, not a blocker.
Not verified
node_modules isn't installed in this checkout, so I couldn't run yarn tsc or the suites. Nothing in this commit could affect either, since no code changed — but CI remains the source of truth for pass/fail.
Thread housekeeping
Listed all threads: 2 open (both claude), the rest already resolved. Both open ones — gateway.ts:484 (finding #1) and timezone.ts:19 (finding #2) — still apply verbatim, since this commit touches neither file, so I left them unresolved rather than re-posting. No new inline comments this pass: 3b59610 introduces no issue, and the one nit above (timezone.test.ts's dropped rationale) isn't worth a thread. Findings #4 and #5 aren't on diff lines and #6's thread was resolved by the author, so those are written out above. No human-authored threads touched.
Task list
- Diff
3393f95..3b59610and confirm it is comment-only - Check each trimmed comment for lost rationale
- Re-verify each open finding against the current tree (
timezone.ts,BaseQuery.js,optionsValidate.ts,server.ts, the mdx section) - List review threads, resolve stale ones (none stale), dedupe
- Post summary
The section listed the accepted values but none of the validation behaviour, while CUBEJS_DEFAULT_TIMEZONE already carried the same warning. State that an invalid zone fails at startup, that UTC offsets are rejected, and that empty entries left by a trailing or repeated comma are ignored.
|
Claude finished @ovr's task in 1m 27s —— View job Re-review of
|
| # | Sev | Location | Issue |
|---|---|---|---|
| 1 | Low | gateway.ts:484 (open thread) |
(a) Joi.object() without .required() accepts undefined, so an absent req.body would pass and body.query would throw a TypeError → 500 instead of 400 — unreachable today (line 474 destructures req.body, express.json() always sets an object) but one token to close; (b) unknown keys are now a hard 400 for the whole request — right default, but a version-skew break worth a release note, and cacheMode (accepted by querySchema, not here) goes from silently-ignored to 400; (c) null/'' timezones used to be forwarded as unset and now 400. Still no route-level negative test: test/index.test.ts:1322-1500 is happy-path only, and the schema tests exercise cubeSqlRequestSchema in isolation, so nothing pins the UserError → handleError → 400 wiring. |
| 2 | Low | optionsValidate.ts:108, server.ts:797 |
The Joi.func() alternative for scheduledRefreshTimeZones remains unvalidated — await this.scheduledRefreshTimeZones(context) lands straight in queryingOptions.timezones (server.ts:797). With the env var canonicalizing at the source and the array form canonicalizing in validateOptions, the function form is the last route where the cross-planner divergence this PR targets survives: a config returning ['utc'] fails Tesseract's case-sensitive parse::<Tz>() (query_tools.rs:61) while the legacy planner accepts it. A canonicalTimezone pass over the resolved list closes it — and would make this commit's "fails at startup" framing true of every route into the option. |
| 3 | Low | timezone.ts:19 (open thread) |
'' is classified as a TypeError ("call-site bug") rather than returning null. Unreachable today — all four callers filter it first (Joi.string()'s string.empty at query.js:62 and optionsValidate.ts:5, .filter(Boolean) at env.ts:275-278, || 'UTC' at env.ts:355, truthiness at BaseQuery.js:307) — but '' is the one bad value most likely to come from user input, and .allow(null, '') on timezoneSchema (the compat option floated on thread #1) would turn a clean 400 into a 500. RangeError would also fit a well-typed-but-empty value better. |
| 4 | Low | BaseQuery.js:307 |
Still truthiness-gated (this.timezone && (typeof … !== 'string' || !canonicalTimezone(…))), so a falsy non-string — 0, false, NaN — skips validation and reaches the dialect's AT TIME ZONE '${this.timezone}' sink. No quote, so not injection, but a DB error rather than a UserError. Gateway routes are covered by Joi.string(); this is the queryRewrite / refresh-scheduler path. Gating on !== undefined && !== null && !== '' closes it, and would also keep '' away from #3's throw. |
| 5 | Low | timezone.test.ts:28-38, base-query.test.ts:140-146 |
Neither negative list has a quote-bearing entry, so the injection vector into AT TIME ZONE '${this.timezone}' (PostgresQuery.ts:28) — the thing this PR is really protecting — has no regression test. One case like "UTC' AT TIME ZONE 'UTC" would pin it. (Author resolved this thread earlier; noted once more, your call.) |
Verified, not a problem
- Commit is docs-only —
git show --statis one file, 8 insertions, 0 deletions; no code or test lines touched. - Startup-failure claim — traced the eager read through the
OptsHandlerconstructor (:47→initializeCoreOptions→:403), so the throw lands at boot as documented.OptsHandler.test.tsalready pins that behavior. - Warning renders — blank lines after
<Warning>and before</Warning>, matching theCUBEJS_DEFAULT_TIMEZONEblock and the repo's Mintlify convention, so the markdown inside will render. - Security fix intact —
this.timezonestill reaches SQL string literals raw across dialects (PostgresQuery.ts:28,ClickHouseQuery.ts:50,SnowflakeQuery.ts:38,BigqueryQuery.ts:45,HiveQuery.ts:30,TrinoQuery.ts:7,VerticaQuery.ts:16,MysqlQuery.ts:49); theBaseQueryconstructor guard closes it on every path. Still worth one line in the PR description — it affects how this gets backported. - tzdb skew — moment-timezone here is much newer than chrono-tz
0.8.2(cubesqlplanner/Cargo.toml:20), so recently-added zone names pass JS validation and fail in the native planner. Follow-up, not a blocker.
Not verified
node_modules isn't installed in this checkout, so I couldn't run the suites or the Mintlify dev server — the render check is by reading the file against the sibling block's structure, and the behavioral claims by reading env.ts/OptsHandler.ts rather than an empirical run. Nothing in this commit could affect CI, since no code changed.
Thread housekeeping
Two threads open, both mine: gateway.ts:484 (finding #1) and timezone.ts:19 (finding #3). This commit touches neither file, so both still apply verbatim — left unresolved rather than re-posted. Nothing became stale this pass; everything else was already resolved. No new inline comments, since d60aa38 introduces no issue. Findings #2, #4 and #5 aren't on diff lines, so they're written out above. No human-authored threads touched.
Task list
- Diff
3b59610..d60aa38and confirm it is docs-only - Verify each documented claim against
env.tsandOptsHandler.ts - Confirm the eager read makes "fails at server startup" accurate
- Check the
<Warning>block against the sibling precedent and Mintlify conventions - Re-verify each remaining open finding against the current tree
- List review threads, resolve stale ones (none stale), dedupe
- Post summary
|
Claude finished @ovr's task in 1m 15s —— View job Re-review of
|
| # | Sev | Location | Issue |
|---|---|---|---|
| 1 | Low | gateway.ts:484 (open thread) |
(a) Joi.object() without .required() accepts undefined, so an absent req.body would pass and body.query would throw a TypeError → 500 instead of 400 — unreachable today (line 474 destructures req.body, express.json() always sets an object) but one token to close; (b) unknown keys are now a hard 400 for the whole request — right default, but a version-skew break worth a release note, and cacheMode (accepted by querySchema, not here) goes from silently-ignored to 400; (c) null/'' timezones used to be forwarded as unset and now 400. Still no route-level negative test: test/index.test.ts:1322-1500 is happy-path only, and the schema tests exercise cubeSqlRequestSchema in isolation, so nothing pins the UserError → handleError → 400 wiring. |
| 2 | Low | timezone.ts:19 (open thread) |
'' is classified as a TypeError ("call-site bug") rather than returning null. Unreachable today — all callers filter it first (Joi.string()'s string.empty at query.js:62 and optionsValidate.ts:5, .filter(Boolean) at env.ts:275-278, || 'UTC' at env.ts:355, truthiness at BaseQuery.js:307) — but '' is the one bad value most likely to come from user input, and .allow(null, '') on timezoneSchema (the compat option floated on thread #1) would turn a clean 400 into a 500. RangeError would also fit a well-typed-but-empty value better. |
| 3 | Low | BaseQuery.js:307 |
Still truthiness-gated (this.timezone && (typeof … !== 'string' || !canonicalTimezone(…))), so a falsy non-string — 0, false, NaN — skips validation and reaches the dialect's AT TIME ZONE '${this.timezone}' sink. No quote, so not injection, but a DB error rather than a UserError. Gateway routes are covered by Joi.string(); this is the queryRewrite / refresh-scheduler path. Gating on !== undefined && !== null && !== '' closes it, and would also keep '' away from #2's throw. |
| 4 | Low | optionsValidate.ts:108, server.ts:797 |
The Joi.func() alternative for scheduledRefreshTimeZones remains unvalidated — its awaited result lands straight in queryingOptions.timezones. With the env var canonicalizing at the source and the array form canonicalizing in validateOptions, the function form is the last route where the cross-planner divergence this PR targets survives: a config returning ['utc'] fails Tesseract's case-sensitive parse::<Tz>() (query_tools.rs:61) while the legacy planner accepts it. A canonicalTimezone pass over the resolved list closes it — and would make the <Warning> this commit edits true of every route into the option, not just the env var. |
| 5 | Low | timezone.test.ts:28-38, base-query.test.ts:140-146 |
Neither negative list has a quote-bearing entry, so the injection vector into AT TIME ZONE '${this.timezone}' (PostgresQuery.ts:28) — the thing this PR is really protecting — has no regression test. One case like "UTC' AT TIME ZONE 'UTC" would pin it. (Author resolved this thread earlier; noted once more, your call.) |
Verified, not a problem
- Commit is docs-only —
git show --statis one file, 1 insertion, 2 deletions; no code or test lines touched, so nothing in CI can shift. - Both surviving warning claims re-checked against
env.ts/OptsHandler.ts/timezone.test.ts; both hold. - The removed claim was also true, so no accuracy issue either way —
env.test.tsstill pins the empty-segment cases, so the behavior stays tested even though it's no longer documented. <Warning>still renders — blank lines after the open tag and before the close, matching theCUBEJS_DEFAULT_TIMEZONEblock.- Security fix intact —
this.timezonestill reaches SQL string literals raw across dialects (PostgresQuery.ts:28,ClickHouseQuery.ts:50,SnowflakeQuery.ts:38,BigqueryQuery.ts:45,HiveQuery.ts:30,TrinoQuery.ts:7,VerticaQuery.ts:16,MysqlQuery.ts:49); theBaseQueryconstructor guard closes it on every path. Still worth one line in the PR description — it affects how this gets backported. - tzdb skew — moment-timezone here is much newer than chrono-tz
0.8.2(cubesqlplanner/Cargo.toml:20), so recently-added zone names pass JS validation and fail in the native planner. Follow-up, not a blocker.
Not verified
node_modules isn't installed in this checkout, so I couldn't run yarn tsc, the suites, or the Mintlify dev server — the render check is by reading the file against the sibling block, and the behavioral claims by reading env.ts/OptsHandler.ts. Nothing in this commit could affect CI, since no code changed.
Thread housekeeping
17 threads total: 15 resolved, 2 open (both mine) — gateway.ts:484 (finding #1) and timezone.ts:19 (finding #2). This commit touches neither file, so both still apply verbatim; left unresolved rather than re-posted. No new inline comments, since 7005ea1 introduces no issue and the one tradeoff noted above isn't worth a thread. Findings #3–#5 aren't on diff lines, so they're written out above. No human-authored threads touched.
Task list
- Diff
d60aa38..7005ea1and confirm it is docs-only - Re-verify the two surviving warning claims against
env.tsandOptsHandler.ts - Check whether the removed sentence was accurate / still covered by tests
- Re-verify each open finding against the current tree
- List review threads, resolve stale ones (none stale), dedupe
- Post summary
The guard only checked that the timezone was a known zone and left the original casing in place, so a lowercase name such as utc reached the dialects verbatim and failed on the native planner, which parses the zone case-sensitively. Assign the canonical name and pass it to the native query params, so both planners see the same zone whichever entry point built the query. A non-string timezone now surfaces as the TypeError canonicalTimezone raises. No route can produce one: they all validate the timezone as a string beforehand.
|
Claude finished @ovr's task in 3m 22s —— View job Re-review of
|
| # | Sev | Location | Issue |
|---|---|---|---|
| 1 | Low | BaseQuery.js:302 (new inline) |
if (this.timezone) leaves the new contract inconsistent for falsy non-strings: 123/{}/true throw TypeError as the tests pin, but 0, false and NaN skip the gate entirely and reach AT TIME ZONE '${this.timezone}' (PostgresQuery.ts:28) as AT TIME ZONE '0' — a DB error rather than a validation one. !== undefined && !== null && !== '' closes it; 0/false are worth adding to the it.each. |
| 2 | Low | BaseQuery.js:274, PreAggregations.ts:380 |
Two readers still take the raw option. The compilerCache.getQueryCache key is still this.options.timezone, so 'utc' and 'UTC' now allocate two entries holding identical SQL (harmless, just a wasted slot — canonicalizing above the getQueryCache call fixes it). And the pre-agg descriptor's timezone: this.query.options?.timezone hands the raw spelling to the orchestrator's localTimestampToUtc/extractDate calls (PreAggregationPartitionRangeLoader.ts:161-200, :463-492) — moment is lenient so ranges resolve the same, but the descriptor and the SQL it describes now disagree on the spelling. |
| 3 | Low | release notes | Canonicalization moves pre-aggregation structure versions. getStructureVersion hashes preAggregation.loadSql (query-orchestrator/src/orchestrator/PreAggregations.ts:74-86), and loadSql embeds the rendered AT TIME ZONE '…', so any tenant currently sending utc — or a lowercase zone via scheduledRefreshTimeZones — gets a new structure version and a one-time rebuild on upgrade. Exactly what the comment this commit replaces was guarding; the tradeoff is right, but it needs an explicit release-note line rather than a surprise rebuild. |
| 4 | Low | gateway.ts:484 (open thread) |
(a) Joi.object() without .required() accepts undefined, so an absent req.body would pass and body.query would throw → 500 rather than 400 — unreachable today (line 474 destructures req.body, express.json() always sets an object) but one token to close; (b) unknown keys are now a hard 400 for the whole request — right default, but a version-skew break worth a release note, and cacheMode (accepted by querySchema, not here) goes from silently-ignored to 400; (c) null/'' timezones used to be forwarded as unset and now 400. Still no route-level negative test: test/index.test.ts:1322-1500 is happy-path only, and the schema tests exercise cubeSqlRequestSchema in isolation, so nothing pins the UserError → handleError → 400 wiring. |
| 5 | Low | timezone.ts:19 (open thread) |
'' is classified as a TypeError ("call-site bug") rather than returning null. Still unreachable — Joi.string()'s string.empty at query.js:62 and optionsValidate.ts:5, .filter(Boolean) at env.ts:275-278, || 'UTC' at env.ts:355, and BaseQuery's truthiness gate all filter it first — but '' is the one bad value most likely to come from user input, and .allow(null, '') on timezoneSchema (the compat option floated on thread #4) would turn a clean 400 into a 500. RangeError would also fit a well-typed-but-empty value better. Note this commit tightens the coupling: BaseQuery's truthiness gate is now the only thing keeping '' away from the throw, and finding #1 asks to replace that gate. |
| 6 | Low | timezone.test.ts:28-38, base-query.test.ts:140-146 |
Neither negative list has a quote-bearing entry, so the injection vector into AT TIME ZONE '${this.timezone}' — the thing this PR is really protecting — has no regression test. One case like "UTC' AT TIME ZONE 'UTC" would pin it. (Author resolved this thread earlier; noted once more, your call.) |
Verified, not a problem
queryRewritecan't produce aTypeError—gateway.ts:1422re-runsnormalizeQueryon the rewritten query, so a hook setting a non-stringtimezoneis caught byJoi.string()as a 400. TheTypeErrorpath is reachable only from config hooks that build queries outside the gateway.- Both native param builders updated —
buildSqlAndParamsRust:956andfindPreAggregationForQueryRust:1014now passthis.timezone, so the native planner sees the canonical name; those were the two sites that mattered for the case-sensitivity mismatch atquery_tools.rs:61. - Partition table names don't embed the timezone, so the rebuild in finding ResultSet pivot methods documentation #3 comes from the
loadSqlhash only — no partition-naming churn on top of it. ''still short-circuits the guard, so this commit doesn't makecanonicalTimezone's empty-string throw reachable.- Security fix intact —
this.timezonestill reaches SQL string literals raw across dialects (PostgresQuery.ts:28,ClickHouseQuery.ts:50,SnowflakeQuery.ts:38,BigqueryQuery.ts:45,HiveQuery.ts:30,TrinoQuery.ts:7,VerticaQuery.ts:16,MysqlQuery.ts:49); the constructor guard closes it on every path. Still worth one line in the PR description — it affects how this gets backported. - tzdb skew — moment-timezone here is much newer than chrono-tz
0.8.2(cubesqlplanner/Cargo.toml:20), so recently-added zone names pass JS validation and fail in the native planner. Follow-up, not a blocker.
Not verified
node_modules isn't installed in this checkout, so I couldn't run yarn tsc or the suites — findings #2 and #3 come from reading the orchestrator's getStructureVersion / PreAggregationPartitionRangeLoader call chain rather than an empirical build-and-compare. CI is the source of truth for pass/fail.
Thread housekeeping
Two threads open, both mine: gateway.ts:484 (finding #4) and timezone.ts:19 (finding #5). This commit touches neither file and both still apply verbatim, so I left them unresolved rather than re-posting. Nothing became stale — the BaseQuery canonicalization thread I'd carried for three passes was already resolved when I accepted the opposite decision, and this commit implements it. Posted one new inline comment (#1–#3, all on the changed lines). Finding #6's thread was resolved by the author, so it's written out above. No human-authored threads touched.
Task list
- Diff
7005ea1..79b1c43and identify what changed - Verify the "no route can produce a non-string" claim, including
queryRewrite - Find every remaining reader of the raw
this.options.timezone - Trace whether canonicalization moves pre-agg structure versions / partition names
- Re-verify each remaining open finding against the current tree
- List review threads, resolve stale ones (none stale), dedupe
- Post inline comment and summary
The wrong-type inputs are unreachable over HTTP — every route validates the timezone as a string before the query is built. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Claude finished @ovr's task in 2m 15s —— View job Re-review of
|
timezone |
behavior at HEAD |
|---|---|
undefined, null |
skipped — intended (trino-presto-date-time-dimension.test.ts:102 passes null) |
'' |
silently skipped → AT TIME ZONE '' |
0, false, NaN |
silently skipped → AT TIME ZONE '0' |
123, {}, true |
TypeError — correct, but no longer tested here |
canonicalTimezone's empty-string throw (3393f95) and its non-string throw are therefore both unreachable through this path for precisely the inputs a truthiness check swallows. Flipping the gate to !== undefined && !== null is the one-line change that makes the helper's documented contract take effect; the inline comment carries the guard plus the two it.each blocks that would pin it.
Findings
| # | Sev | Location | Issue |
|---|---|---|---|
| 1 | Low | BaseQuery.js:304, base-query.test.ts (new inline) |
Truthiness gate lets ''/0/false/NaN skip validation entirely and reach the dialect's AT TIME ZONE '${this.timezone}' sink (PostgresQuery.ts:28). No quote, so not injection, but a DB error rather than a UserError/TypeError — and this commit removes the last schema-compiler coverage of the throw branch, so nothing pins any of it. |
| 2 | Low | BaseQuery.js:274, PreAggregations.ts:380 |
Two readers still take the raw option. The compilerCache.getQueryCache key is this.options.timezone, so 'utc' and 'UTC' now allocate two entries holding identical SQL (harmless, one wasted slot — canonicalizing above the getQueryCache call collapses them). And the pre-agg descriptor's timezone: this.query.options?.timezone hands the raw spelling to the orchestrator's localTimestampToUtc/extractDate calls while the SQL it describes carries the canonical one; moment is lenient so ranges resolve the same, but the two disagree. |
| 3 | Low | release notes | Canonicalization moves pre-aggregation structure versions. getStructureVersion hashes preAggregation.loadSql (query-orchestrator/src/orchestrator/PreAggregations.ts:74-86) and loadSql embeds the rendered AT TIME ZONE '…', so any tenant currently sending utc — or a lowercase zone via scheduledRefreshTimeZones — gets a one-time rebuild on upgrade. Right tradeoff, but it should be an explicit release-note line rather than a surprise. Same note should mention +05:00 now hard-failing, and that unknown keys on /v1/cubesql are now a 400. |
| 4 | Low | optionsValidate.ts:108, server.ts:797-799 |
Re-verified: scheduledRefreshTimeZones is Joi.alternatives().try(Joi.array().items(timezoneSchema), Joi.func()), and await this.scheduledRefreshTimeZones(context) lands straight in queryingOptions.timezones. The Joi.func() branch is unvalidated — but now that BaseQuery canonicalizes (79b1c43), a hook returning ['utc'] is fixed up at the choke point rather than failing in Tesseract, so this is down to "no early, clear error" rather than a divergence. |
| 5 | Low | timezone.test.ts:28-38, base-query.test.ts:140-146 |
Neither negative list has a quote-bearing entry, so the injection vector into AT TIME ZONE '${this.timezone}' — the thing this PR is really protecting — has no regression test. One case like "UTC' AT TIME ZONE 'UTC" would pin it. (Thread resolved earlier; noted once more, your call.) |
Verified, not a problem
- Commit is test-only —
git show --statis one file, 0 insertions / 11 deletions; no source or behavior change. - The deleted coverage is duplicated at the unit level in
timezone.test.ts, which still exercises every wrong-type case including0/false. nullmust stay "unset" —trino-presto-date-time-dimension.test.ts:102constructs a query withtimezone: null, so the suggested gate deliberately keepsundefined/nullaccepted.- No route can deliver a non-string —
Joi.string()gatesquery.js:62(used byquerySchema, the pre-agg schemas andpreAggsJobsRequestSchema) andcubeSqlRequestSchemacovers/v1/cubesql;queryRewrite's output is re-validated atgateway.ts:1422. - Security fix intact —
this.timezonestill reaches SQL string literals raw across dialects (PostgresQuery.ts:28,ClickHouseQuery.ts:50,SnowflakeQuery.ts:38,BigqueryQuery.ts:45,HiveQuery.ts:30,TrinoQuery.ts:7,VerticaQuery.ts:16,MysqlQuery.ts:49); the constructor guard closes it for every string input. Still worth one line in the PR description — it affects how this gets backported. - tzdb skew — moment-timezone here is much newer than chrono-tz
0.8.2(cubesqlplanner/Cargo.toml:20), so recently-added zone names pass JS validation and fail in the native planner. Follow-up, not a blocker.
Not verified
node_modules isn't installed in this checkout, so I couldn't run yarn tsc or the suites — nothing in this commit could affect compilation, and the deleted tests can't fail, but CI remains the source of truth. Findings #2 and #3 come from reading the orchestrator's getStructureVersion / PreAggregationPartitionRangeLoader call chain rather than a build-and-compare.
Thread housekeeping
All 18 threads on this PR are already resolved — nothing to resolve, nothing to dedupe against. Posted one new inline comment (finding #1). It restates the concern from the now-resolved BaseQuery.js:311 thread, but on a different file and line, and because the change you asked for on that thread was never pushed (403) — so it's the live version of the request rather than a duplicate. Findings #2–#5 aren't on diff lines, so they're written out above. No human-authored threads touched.
Task list
- Diff
79b1c43..b4d5ef6and identify what changed - Check whether the deleted cases are covered elsewhere (
timezone.test.ts) - Verify the commit message's "unreachable over HTTP" claim across every route
- Re-check the
BaseQueryguard against the explicit-error request from the prior round - Confirm
nullis a supported "unset" spelling before suggesting a stricter gate - Re-verify each remaining open finding against the current tree
- List review threads, resolve stale ones (none open), dedupe
- Post inline comment and summary
| const query = buildTimezoneQuery(timezone); | ||
| expect(query.timezone).toBe(expected); | ||
| expect(query.buildSqlAndParams()[0]).toContain(`AT TIME ZONE '${expected}'`); | ||
| }); |
There was a problem hiding this comment.
Removing these is defensible on coverage grounds — timezone.test.ts:53-64 already pins 123/0/{}/[]/true/false as TypeError at the unit level, so the only thing lost is the assertion that BaseQuery lets that throw propagate rather than wrapping it in a UserError. Cheap to lose.
What concerns me is what it leaves behind. Two comments ago you said you wanted an explicit error rather than a silent ignore at BaseQuery.js:304, and that change never landed — the guard is still if (this.timezone), so the truthy non-strings these tests covered throw while the falsy ones don't:
timezone |
current behavior |
|---|---|
undefined, null |
skipped (intended — trino-presto-date-time-dimension.test.ts:102 relies on null) |
'' |
silently skipped → AT TIME ZONE '' |
0, false, NaN |
silently skipped → AT TIME ZONE '0' |
123, {}, true |
TypeError (no longer tested here) |
So canonicalTimezone's empty-string throw (3393f95) and its non-string throw are both unreachable through this path for exactly the inputs a truthiness check swallows, and after this commit nothing in the schema-compiler suite pins any of it. If the intent is that a bad argument fails loudly, the gate is the thing to change, not the tests:
| }); | |
| }); | |
| // A falsy value such as '' or 0 is a bad argument rather than "no timezone", so it | |
| // must reach canonicalTimezone and fail instead of flowing into convertTz(). | |
| it.each([ | |
| '', | |
| 0, | |
| false, | |
| ])('rejects falsy non-unset timezone %j', async (timezone) => { | |
| await compilers.compiler.compile(); | |
| expect(() => buildTimezoneQuery(timezone as any)).toThrow(TypeError); | |
| }); | |
| it.each([ | |
| undefined, | |
| null, | |
| ])('accepts an unset timezone %j', async (timezone) => { | |
| await compilers.compiler.compile(); | |
| expect(() => buildTimezoneQuery(timezone as any)).not.toThrow(); | |
| }); |
paired with if (this.timezone !== undefined && this.timezone !== null) in the constructor. Nothing in packages/*/src passes an empty timezone today (RefreshScheduler.ts:271 and query.js:456 both || 'UTC', env.ts:355 falls back to 'UTC'), so I'd expect no fallout beyond the null case above, which stays accepted.
Backport of d1ba22a to LTS v1.4. `canonicalTimezone()` (new, in `@cubejs-backend/shared`) resolves a value to a canonical tz-database zone name case-insensitively, or null. It is wired into every entry point a timezone can arrive through: | Sink | Guard | | --- | --- | | REST query | `timezoneSchema` on `querySchema` | | `/v1/cubesql` body | new `cubeSqlRequestSchema` | | Pre-agg jobs / preview | `preAggsJobsRequestSchema`, `queryPreAggregations*Schema` | | `CUBEJS_SCHEDULED_REFRESH_TIMEZONES` | `getEnv` throws `InvalidConfiguration` | | `CreateOptions.scheduledRefreshTimeZones` | `validateOptions` | | Everything else (queryRewrite, refresh scheduler, SQL API) | `BaseQuery` constructor backstop | The Joi schemas now return their validated `value`, so the canonical name is what reaches the dialects' `convertTz()` — the native planner parses zones case-sensitively, so `utc` had to become `UTC` before it got there. `optionsValidate`'s default export becomes the named `validateOptions`, which returns the sanitized options; `OptsHandler.assertOptions` becomes `sanitizeOptions` and feeds them into `initializeCoreOptions`. Differences from master, all because the target lacks features that landed later: | Dropped | Reason | | --- | --- | | `CUBEJS_DEFAULT_TIMEZONE` validation + its docs and the `OptsHandler` startup probe | The env var itself does not exist on v1.4 | | `preciseDecimalInCubestore` | Unrelated, adjacent to the same env.ts hunk | | The v1.7.0 `CreateOptions.dbType` removal throw | v1.4 still supports `dbType`; its handling is kept as-is | | `execSql`'s `timezone`/`throwContinueWait`/`requestId` args | v1.4's `execSql` takes 4 params | | `responseFormat: 'columnar'` test case | v1.4 accepts `default` and `compact` only | `cubeSqlRequestSchema` still accepts `timezone` and `throwContinueWait` so that bodies which work today keep working; v1.4 ignores both, as it did before. Verified: backend-shared timezone/env suites, api-gateway (new normalize-query.test.ts, 33 tests), server-core optionsValidate + the 3 new OptsHandler timezone tests, and the full schema-compiler unit suite. Remaining failures in those packages reproduce identically on the parent commit (numeric-to-string serialization in api-gateway, stale sibling `dist` in server-core, `error-reporter` in schema-compiler). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit d1ba22a)

The query
timezonewas only validated as a free-form string, so invalid or malformed values were accepted and handled inconsistently between the native (Tesseract) and legacy planners. Validate it against known IANA zone names so bad values are rejected early with a clear error.