{"record":{"id":"5e6fe1ae87b1ceeb","repo":"apache/dubbo","slug":"value-is-not-a-valid-iso-8601-duration","errorCode":null,"errorMessage":"'${value}' is not a valid ISO-8601 duration","messagePattern":"'(.+?)' is not a valid ISO-8601 duration","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/convert/StringToDurationConverter.java","lineNumber":73,"sourceCode":"                                    ? TimeUnit.fromSuffix(suffix)\n                                    : TimeUnit.fromChronoUnit(unit))\n                            .parse(matcher.group(1));\n                } catch (Exception ex) {\n                    throw new IllegalArgumentException(\"'\" + value + \"' is not a valid simple duration\", ex);\n                }\n            }\n        },\n\n        /**\n         * ISO-8601 formatting.\n         */\n        ISO8601(\"^[+-]?[pP].*$\") {\n            @Override\n            public Duration parse(String value, ChronoUnit unit) {\n                try {\n                    return Duration.parse(value);\n                } catch (Exception ex) {\n                    throw new IllegalArgumentException(\"'\" + value + \"' is not a valid ISO-8601 duration\", ex);\n                }\n            }\n        };\n\n        private final Pattern pattern;\n\n        DurationStyle(String pattern) {\n            this.pattern = Pattern.compile(pattern);\n        }\n\n        protected final boolean matches(String value) {\n            return this.pattern.matcher(value).matches();\n        }\n\n        protected final Matcher matcher(String value) {\n            return this.pattern.matcher(value);\n        }\n","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/convert/StringToDurationConverter.java#L55-L91","documentation":"Thrown by DurationStyle.ISO8601.parse() when a value matches the ISO-8601 pattern (^([+-]?[pP].*$)) but Duration.parse(value) fails — meaning the string starts with P/p (so it's routed here) but does not conform to the ISO-8601 duration grammar (e.g. Pxyz). Java's Duration.parse requires the standard form like PT1H30M, P1D, etc.","triggerScenarios":"Calling DurationStyle.detectAndParse(value) where value starts with P or p but is not a syntactically valid ISO-8601 duration. For example \"P\", \"Px\", \"PT\", or \"P1\" (missing time designator). Values like \"PT0.5S\" or \"P1DT2H\" are valid.","commonSituations":"Manually writing an ISO-8601 duration string with a typo. Confusing the date-period format with the duration format. A value that coincidentally starts with 'P' but was never intended to be ISO-8601 (e.g. a hostname or property name beginning with P).","solutions":["Use a correct ISO-8601 duration: start with P, use T before time components (e.g. PT5M30S for 5 min 30 sec).","If the value was not meant to be ISO-8601 but starts with P/p, switch to the simple format (e.g. 5m or 300s) so detect() routes it to SIMPLE.","Check the chained cause (DateTimeParseException) for the exact parse position of the failure."],"exampleFix":"// before\ndubbo.provider.timeout=PT\n\n// after\ndubbo.provider.timeout=PT5S  // or simply: 5000 (ms)","handlingStrategy":"validation","validationCode":"try {\n    Duration.parse(value);\n} catch (DateTimeParseException e) {\n    // not valid ISO-8601 — log or fall back\n}","typeGuard":"static boolean isValidIsoDuration(String v) {\n    if (v == null || v.isEmpty()) return false;\n    try { Duration.parse(v); return true; }\n    catch (Exception e) { return false; }\n}","tryCatchPattern":"try {\n    return DurationStyle.ISO8601.parse(value, null);\n} catch (IllegalArgumentException e) {\n    return Duration.ofMillis(defaultMillis);\n}","preventionTips":["Use standard ISO-8601 form starting with P (e.g. PT5M30S).","If the value was not meant to be ISO-8601 but starts with P, use simple format instead.","Test duration strings in isolation before deployment."],"tags":["converter","duration","iso-8601","configuration"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}