{"record":{"id":"4e255aa26b5439d3","repo":"apache/flink","slug":"the-value-number-cannot-be-represented-as-dur","errorCode":null,"errorMessage":"The value '${number}' cannot be represented as Duration (numeric overflow).","messagePattern":"The value '(.+?)' cannot be represented as Duration \\(numeric overflow\\)\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/TimeUtils.java","lineNumber":122,"sourceCode":"\n        final ChronoUnit unit;\n        if (unitLabel.isEmpty()) {\n            unit = ChronoUnit.MILLIS;\n        } else {\n            unit = LABEL_TO_UNIT_MAP.get(unitLabel);\n        }\n        if (unit == null) {\n            throw new IllegalArgumentException(\n                    \"Time interval unit label '\"\n                            + unitLabel\n                            + \"' does not match any of the recognized units: \"\n                            + TimeUnit.getAllUnits());\n        }\n\n        try {\n            return convertBigIntToDuration(value, unit);\n        } catch (ArithmeticException e) {\n            throw new IllegalArgumentException(\n                    \"The value '\"\n                            + number\n                            + \"' cannot be represented as Duration (numeric overflow).\",\n                    e);\n        }\n    }\n\n    private static Duration convertBigIntToDuration(BigInteger value, ChronoUnit unit) {\n        final BigInteger nanos = value.multiply(BigInteger.valueOf(unit.getDuration().toNanos()));\n\n        final BigInteger[] dividedAndRemainder = nanos.divideAndRemainder(NANOS_PER_SECOND);\n        return Duration.ofSeconds(dividedAndRemainder[0].longValueExact())\n                .plusNanos(dividedAndRemainder[1].longValueExact());\n    }\n\n    private static Map<String, ChronoUnit> initMap() {\n        Map<String, ChronoUnit> labelToUnit = new HashMap<>();\n        for (TimeUnit timeUnit : TimeUnit.values()) {","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/TimeUtils.java#L104-L140","documentation":"parseDuration converts the parsed BigInteger value plus unit into a java.time.Duration via seconds/nanoseconds arithmetic including longValueExact(). An ArithmeticException (overflow of Long.MAX_VALUE seconds or nanos) is wrapped in this IllegalArgumentException, meaning the requested duration exceeds what Duration can represent (~292 years).","triggerScenarios":"Calling TimeUtils.parseDuration(\"999999999 d\") or any value/unit combination whose nanosecond total exceeds Long.MAX_VALUE; also huge values in small units like \"9223372036854775807 ns\" boundaries.","commonSituations":"Users entering enormous numbers to mean 'effectively infinite' timeout; automation scripts multiplying default values by large factors; copy-paste errors adding extra digits.","solutions":["Use a realistic duration; if the intent is 'no timeout', check the option's documented sentinel (often 0 or -1 handled as infinity before parsing).","Cap user-supplied durations at a sane maximum (e.g. Long.MAX_VALUE days is unnecessary; use days unit).","Trim accidental extra digits from config values."],"exampleFix":"# before\nakka.ask.timeout=999999999999 d\n\n# after\nakka.ask.timeout=1 h","handlingStrategy":"validation","validationCode":"Duration max = Duration.ofSeconds(Long.MAX_VALUE, 999_999_999);\n// pre-check magnitude: parse number+unit yourself and compare\nBigInteger nanos = value.multiply(BigInteger.valueOf(unit.toNanos()));\nif (nanos.compareTo(BigInteger.valueOf(max.toNanos())) > 0) throw new IllegalArgumentException(\"Duration too large\");","typeGuard":null,"tryCatchPattern":"try { TimeUtils.parseDuration(t); }\ncatch (IllegalArgumentException e) { /* cap or reject at config boundary */ }","preventionTips":["Cap user-supplied durations at a sane maximum at the config boundary.","Use days ('d') for large durations to keep numbers small.","Never encode 'infinite' as a gigantic duration; use the option's sentinel."],"tags":["configuration","duration","overflow","parsing"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}