{"record":{"id":"815f1822aea661d7","repo":"apache/dubbo","slug":"value-is-not-a-valid-duration","errorCode":null,"errorMessage":"'${value}' is not a valid duration","messagePattern":"'(.+?)' is not a valid duration","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/convert/StringToDurationConverter.java","lineNumber":152,"sourceCode":"        public static Duration detectAndParse(String value, ChronoUnit unit) {\n            return detect(value).parse(value, unit);\n        }\n\n        /**\n         * Detect the style from the given source value.\n         *\n         * @param value the source value\n         * @return the duration style\n         * @throws IllegalArgumentException if the value is not a known style\n         */\n        public static DurationStyle detect(String value) {\n            Assert.notNull(value, \"Value must not be null\");\n            for (DurationStyle candidate : values()) {\n                if (candidate.matches(value)) {\n                    return candidate;\n                }\n            }\n            throw new IllegalArgumentException(\"'\" + value + \"' is not a valid duration\");\n        }\n\n        /**\n         * Time Unit that support.\n         */\n        enum TimeUnit {\n\n            /**\n             * Nanoseconds.\n             */\n            NANOS(ChronoUnit.NANOS, \"ns\", Duration::toNanos),\n\n            /**\n             * Microseconds.\n             */\n            MICROS(ChronoUnit.MICROS, \"us\", (duration) -> duration.toNanos() / 1000L),\n\n            /**","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/convert/StringToDurationConverter.java#L134-L170","documentation":"Thrown by DurationStyle.detect(value) when the value matches NEITHER the SIMPLE pattern nor the ISO-8601 pattern. detect() iterates all DurationStyle enum values and throws if none matches. This means the string is structurally unrecognizable as any supported duration format.","triggerScenarios":"Calling DurationStyle.detect(value) or detectAndParse(value) with a value that is not purely numeric-with-optional-suffix and does not start with P/p. Examples: empty-after-trim strings, \"abc\", \"1.5s\" (decimal not supported in SIMPLE), \"1.5e3\", \"@500ms\".","commonSituations":"Supplying a floating-point duration like 1.5s (Dubbo's SIMPLE pattern only accepts integers). Supplying a value with leading/trailing special characters. A null-guarded but whitespace-only value. Confusion with Spring Boot's relaxed duration format that allows decimals.","solutions":["If you need a fractional duration, convert it to an integer in a smaller unit (e.g. 1500ms instead of 1.5s).","Ensure the value is either: an integer optionally followed by a supported suffix, or a valid ISO-8601 duration starting with P.","Strip any non-essential whitespace or special characters from the value before passing it to the converter."],"exampleFix":"// before\ndubbo.consumer.timeout=1.5s\n\n// after\ndubbo.consumer.timeout=1500ms","handlingStrategy":"validation","validationCode":"try {\n    DurationStyle.detect(value);\n} catch (IllegalArgumentException e) {\n    // unrecognized format — handle before calling detectAndParse\n}","typeGuard":"static boolean isRecognizableDuration(String v) {\n    if (v == null) return false;\n    return v.matches(\"[+-]?\\\\\\\\d+[a-zA-Z]{0,2}\") || v.matches(\"[+-]?[pP].*\");\n}","tryCatchPattern":"try {\n    return DurationStyle.detectAndParse(value);\n} catch (IllegalArgumentException e) {\n    return Duration.ofMillis(defaultMillis);\n}","preventionTips":["Ensure duration values are either integer+suffix or valid ISO-8601.","Avoid decimal values — convert to smaller integer units.","Strip whitespace and special characters from config values."],"tags":["converter","duration","configuration","parse-error"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}