{"record":{"id":"452dee9c05bac6e7","repo":"prestodb/presto","slug":"invalid-offset-minutes-s","errorCode":null,"errorMessage":"Invalid offset minutes %s","messagePattern":"Invalid offset minutes (.+?)","errorType":"validation","errorClass":"InvalidFunctionArgumentException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/type/TimeZoneKey.java","lineNumber":147,"sourceCode":"\n        TimeZoneKey zoneKey = ZONE_ID_TO_KEY.get(zoneId.toLowerCase(ENGLISH));\n        if (zoneKey == null) {\n            zoneKey = ZONE_ID_TO_KEY.get(normalizeZoneId(zoneId));\n        }\n        if (zoneKey == null) {\n            throw new TimeZoneNotSupportedException(zoneId);\n        }\n        return zoneKey;\n    }\n\n    public static TimeZoneKey getTimeZoneKeyForOffset(long offsetMinutes)\n    {\n        if (offsetMinutes == 0) {\n            return UTC_KEY;\n        }\n\n        if (!(offsetMinutes >= OFFSET_TIME_ZONE_MIN && offsetMinutes <= OFFSET_TIME_ZONE_MAX)) {\n            throw new InvalidFunctionArgumentException(format(\"Invalid offset minutes %s\", offsetMinutes));\n        }\n        TimeZoneKey timeZoneKey = OFFSET_TIME_ZONE_KEYS[((int) offsetMinutes) - OFFSET_TIME_ZONE_MIN];\n        if (timeZoneKey == null) {\n            throw new TimeZoneNotSupportedException(zoneIdForOffset(offsetMinutes));\n        }\n        return timeZoneKey;\n    }\n\n    private final String id;\n\n    private final short key;\n\n    public TimeZoneKey(String id, short key)\n    {\n        this.id = requireNonNull(id, \"id is null\");\n        if (key < 0) {\n            throw new IllegalArgumentException(\"key is negative\");\n        }","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/type/TimeZoneKey.java#L129-L165","documentation":"TimeZoneKey.getTimeZoneKeyForOffset resolves time zones expressed as minute offsets (e.g. +05:30). Offsets must lie within OFFSET_TIME_ZONE_MIN..OFFSET_TIME_ZONE_MAX (±14 hours, in minutes); anything outside throws InvalidFunctionArgumentException with \"Invalid offset minutes %s\". Valid in-range offsets map into the precomputed OFFSET_TIME_ZONE_KEYS table.","triggerScenarios":"Calling getTimeZoneKeyForOffset(offsetMinutes) with offsetMinutes outside ±14h range (offsetMinutes < -840 or > 840, excluding 0 which returns UTC_KEY).","commonSituations":"Parsing malformed session zone strings like '+25:00'; deserializing corrupted offsets from clients or stored plans; connectors converting arbitrary user input to offsets without validation.","solutions":["Validate the offset is within [-840, 840] minutes before calling getTimeZoneKeyForOffset.","Parse zone strings with zoneIdForOffset/getTimeZoneKey and catch InvalidFunctionArgumentException to reject bad input.","Normalize offsets exceeding ±14h (the ISO max) — treat them as invalid user data."],"exampleFix":"// before\nTimeZoneKey key = TimeZoneKey.getTimeZoneKeyForOffset(offsetMinutes);\n// after\nif (offsetMinutes < -840 || offsetMinutes > 840) throw new IllegalArgumentException(\"offset out of range\");\nTimeZoneKey key = TimeZoneKey.getTimeZoneKeyForOffset(offsetMinutes);","handlingStrategy":"validation","validationCode":"if (offsetMinutes != 0 && (offsetMinutes < -840 || offsetMinutes > 840)) throw new IllegalArgumentException(\"offset out of supported ±14h range\");","typeGuard":"boolean isValidOffsetMinutes(long m) { return m == 0 || (m >= -840 && m <= 840); }","tryCatchPattern":"try { TimeZoneKey.getTimeZoneKeyForOffset(offsetMinutes); } catch (InvalidFunctionArgumentException e) { /* reject or normalize the offset */ }","preventionTips":["Validate offsets against the ±14-hour ISO limit at input parsing time.","Sanitize session time zone strings from clients before converting to offsets.","Reject rather than wrap offsets beyond the supported range — they indicate corrupt input."],"tags":["timezone","validation","argument"],"backgroundTag":"invalid-timezone-offset","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}