{"record":{"id":"94744dab02522625","repo":"quarkusio/quarkus","slug":"invalid-duration-value","errorCode":null,"errorMessage":"Invalid duration: ${value}","messagePattern":"Invalid duration: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/runtime/src/main/java/io/quarkus/runtime/configuration/DurationConverter.java","lineNumber":79,"sourceCode":"                return Duration.ofMillis(Long.parseLong(num));\n        }\n\n        // cases handled by Duration.parse(), we add the P/PT prefix if needed\n        try {\n            if (isDecimal(numericPart)) {\n                if (lastLower == 'h' || lastLower == 'm' || lastLower == 's') {\n                    return Duration.parse(PERIOD_OF_TIME + value);\n                } else if (lastLower == 'd') {\n                    return Duration.parse(PERIOD + value);\n                }\n            }\n            // Handle \"1h30m\" style (DIGITS_AND_UNIT)\n            if (startsLikeDigits(value)) {\n                return Duration.parse(PERIOD_OF_TIME + value);\n            }\n            return Duration.parse(value);\n        } catch (Exception e) {\n            throw new IllegalArgumentException(\"Invalid duration: \" + value, e);\n        }\n    }\n\n    private static boolean isNumeric(String s) {\n        int len = s.length();\n        if (len == 0) {\n            return false;\n        }\n        int i = (s.charAt(0) == '-' || s.charAt(0) == '+') ? 1 : 0;\n        if (i == len) {\n            return false;\n        }\n        for (; i < len; i++) {\n            char c = s.charAt(i);\n            if (c < '0' || c > '9') {\n                return false;\n            }\n        }","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/runtime/src/main/java/io/quarkus/runtime/configuration/DurationConverter.java#L61-L97","documentation":"DurationConverter.parseDuration() converts config strings to java.time.Duration, supporting plain numbers, '1h30m' style compound values, and standard ISO-8601. Any parse failure is wrapped in IllegalArgumentException(\"Invalid duration: <value>\").","triggerScenarios":"Setting a duration-typed property (timeouts, intervals, TTLs) with an unparseable value: misspelled units ('30sec' instead of '30s'), stray whitespace inside, negative in the wrong format, or a non-ISO string like '5 minutes'.","commonSituations":"Typos like '30ms s', 'PT' missing for ISO style, using '1h 30m' with a space, env-var values with trailing spaces or quotes, upgrading Quarkus and the converter is stricter than the old parser.","solutions":["Use accepted forms: '5S'/'5s', ISO-8601 'PT30S', 'PT1H30M', or compound '1h30m' without spaces.","Remove stray whitespace/quotes from the value (env vars especially).","Verify unit letters: s, m, h, d (and ms-style handling per converter docs).","Test the literal with Duration.parse('PT'+value) locally to see the underlying error."],"exampleFix":"# before\nquarkus.http.read-timeout=30 seconds\n# after\nquarkus.http.read-timeout=30s","handlingStrategy":"validation","validationCode":"boolean isValidDuration(String s) {\n    if (s == null || s.isBlank()) return false;\n    String v = s.trim();\n    try {\n        if (v.chars().allMatch(Character::isDigit)) return true; // seconds\n        java.time.Duration.parse(v.startsWith(\"P\") ? v : \"PT\" + v);\n        return true;\n    } catch (Exception e) { return false; }\n}","typeGuard":"java.time.Duration tryParseDuration(String s) {\n    try { return (s == null || s.isBlank()) ? null : java.time.Duration.parse(s.matches(\"\\\\d+\") ? \"PT\" + s.trim() + \"S\" : s.trim()); }\n    catch (Exception e) { return null; }\n}","tryCatchPattern":"try {\n    // use converted Duration\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Invalid duration:\")) {\n        log.errorf(\"Fix duration format (e.g. 30s, PT30S, 1h30m): %s\", e.getMessage());\n    } else { throw e; }\n}","preventionTips":["Use compact forms: 30s, 5m, 1h30m or ISO-8601 PT.. notation","No spaces or quotes inside the value","Sanitize env-var values (trailing whitespace, CR) before they reach config"],"tags":["configuration","duration","converter","parsing"],"backgroundTag":"invalid-config-value","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}