{"record":{"id":"f917220b6ad8efe8","repo":"cube-js/cube","slug":"incorrect-timezone-this-timezone","errorCode":null,"errorMessage":"Incorrect timezone ${this.timezone}","messagePattern":"Incorrect timezone (.+?)","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/adapter/BaseQuery.js","lineNumber":308,"sourceCode":"      localRefreshKey: this.options.localRefreshKey,\n      from: this.options.from,\n      multiStageQuery: this.options.multiStageQuery,\n      multiStageDimensions: this.options.multiStageDimensions,\n      multiStageTimeDimensions: this.options.multiStageTimeDimensions,\n      subqueryJoins: this.options.subqueryJoins,\n      joinHints: this.options.joinHints,\n      maskedMembers: this.options.maskedMembers,\n    });\n    this.from = this.options.from;\n    this.multiStageQuery = this.options.multiStageQuery;\n    this.timezone = this.options.timezone;\n\n    // Backstop for every dialect convertTz() sink: callers that bypass the API gateway\n    // (queryRewrite, refresh scheduler, SQL API sessions) reach the dialects through here.\n    if (this.timezone) {\n      const timezone = canonicalTimezone(this.timezone);\n      if (!timezone) {\n        throw new UserError(`Incorrect timezone ${this.timezone}`);\n      }\n\n      this.timezone = timezone;\n    }\n\n    this.rowLimit = this.options.rowLimit;\n    this.offset = this.options.offset;\n    /** @type {import('./PreAggregations').PreAggregations} */\n    this.preAggregations = this.newPreAggregations();\n    /** @type {import('./BaseMeasure').BaseMeasure[]} */\n    this.measures = (this.options.measures || []).map(this.newMeasure.bind(this));\n    /** @type {import('./BaseDimension').BaseDimension[]} */\n    this.dimensions = (this.options.dimensions || []).map(this.newDimension.bind(this));\n    /** @type {import('./BaseDimension').BaseDimension[]} */\n    this.multiStageDimensions = (this.options.multiStageDimensions || []).map(this.newDimension.bind(this));\n    /** @type {import('./BaseTimeDimension').BaseTimeDimension[]} */\n    this.multiStageTimeDimensions = (this.options.multiStageTimeDimensions || []).map(this.newTimeDimension.bind(this));\n    /** @type {import('./BaseSegment').BaseSegment[]} */","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js#L290-L326","documentation":"BaseQuery canonicalizes the query's timezone through canonicalTimezone() so every SQL dialect's convertTz() receives a valid zone. If the provided timezone string cannot be canonicalized (unknown or invalid IANA name/offset), the query is rejected with this UserError.","triggerScenarios":"Setting query.timezone (or the API gateway timezone parameter) to a value like 'PST', 'America', 'UTC+5 ' (malformed), or a locale name not resolvable by the Intl/IANA database.","commonSituations":"Accepting raw browser/device timezone strings from clients, abbreviations like 'EST'/'CET', typos such as 'Europ/Berlin', or environments with an outdated ICU/timezone database.","solutions":["Use a valid IANA timezone name, e.g. 'America/New_York' or 'UTC'","Map abbreviation inputs (EST, PST) to IANA names before sending","Trim/format the string and check for typos against the tz database","Update the runtime (Node/ICU) if a valid IANA name is still rejected"],"exampleFix":"// before\n{ timezone: 'PST' }\n// after\n{ timezone: 'America/Los_Angeles' }","handlingStrategy":"validation","validationCode":"function isValidTimezone(tz) {\n  try { new Intl.DateTimeFormat('en-US', { timeZone: tz }); return true; }\n  catch { return false; }\n}\nif (query.timezone && !isValidTimezone(query.timezone)) {\n  query.timezone = 'UTC'; // or reject the request\n}","typeGuard":"const isIanaTimezone = (tz) => typeof tz === 'string' && (() => { try { Intl.DateTimeFormat(undefined, { timeZone: tz }); return true; } catch { return false; } })();","tryCatchPattern":"try {\n  await cube.query(query);\n} catch (e) {\n  if (/Incorrect timezone/.test(e.message)) {\n    query.timezone = 'UTC';\n    return cube.query(query);\n  }\n  throw e;\n}","preventionTips":["Use Intl.DateTimeFormat timeZone validation client-side before sending","Convert abbreviations (EST, PST) to IANA names at the edge","Never pass raw OS tz strings; normalize with a mapping library like luxon/dayjs","Keep Node/ICU updated so modern IANA names resolve"],"tags":["timezone","validation","query"],"backgroundTag":"invalid-timezone","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}