{"record":{"id":"8048bd8a888752c8","repo":"apache/dubbo","slug":"value-is-not-a-valid-simple-duration","errorCode":null,"errorMessage":"'${value}' is not a valid simple duration","messagePattern":"'(.+?)' is not a valid simple duration","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/convert/StringToDurationConverter.java","lineNumber":59,"sourceCode":"\n    enum DurationStyle {\n\n        /**\n         * Simple formatting, for example '1s'.\n         */\n        SIMPLE(\"^([+-]?\\\\d+)([a-zA-Z]{0,2})$\") {\n            @Override\n            public Duration parse(String value, ChronoUnit unit) {\n                try {\n                    Matcher matcher = matcher(value);\n                    Assert.assertTrue(matcher.matches(), \"Does not match simple duration pattern\");\n                    String suffix = matcher.group(2);\n                    return (StringUtils.isNotBlank(suffix)\n                                    ? 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","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/convert/StringToDurationConverter.java#L41-L77","documentation":"Thrown by DurationStyle.SIMPLE.parse() when a value matches the simple-duration regex pattern ([+-]?\\d+)([a-zA-Z]{0,2}) but fails to parse — most often because the unit suffix is unrecognized, or because an inner assertion failed. The simple format expects a number followed by an optional unit suffix like ns, us, ms, s, m, h, d.","triggerScenarios":"Calling DurationStyle.detectAndParse(value) where value looks numeric with a suffix (e.g. \"100xy\") and matches the SIMPLE pattern, but the suffix is not one of: ns, us, ms, s, m, h, d. Also fires if the numeric part overflows Long.parseLong.","commonSituations":"Setting a Dubbo timeout, delay, or duration property with a wrong unit suffix. For example dubbo.provider.timeout=500ms is valid, but dubbo.provider.timeout=500millis or dubbo.provider.timeout=500x is not. Confusion between Spring Duration format (PT0.5S) and Dubbo's simple format.","solutions":["Use a supported suffix: ns, us, ms, s, m, h, or d (e.g. 500ms, 3s).","If the value has no suffix, the default unit is milliseconds — just supply the bare number.","If you need ISO-8601 format, prefix with P (e.g. PT0.5S) so detect() routes to the ISO8601 style instead of SIMPLE.","Check the chained cause exception for the exact reason (unknown suffix vs. number overflow)."],"exampleFix":"// before\ndubbo.provider.timeout=500millis\n\n// after\ndubbo.provider.timeout=500ms","handlingStrategy":"validation","validationCode":"private static final Set<String> VALID_SUFFIXES = Set.of(\"ns\",\"us\",\"ms\",\"s\",\"m\",\"h\",\"d\");\nString trimmed = value.trim();\nif (!trimmed.matches(\"[+-]?\\\\d+[a-zA-Z]{0,2}\")) return null;\n// further check suffix if present\n","typeGuard":"static boolean isValidSimpleDuration(String v) {\n    if (v == null) return false;\n    Matcher m = Pattern.compile(\"([+-]?\\\\\\\\d+)([a-zA-Z]{0,2})\").matcher(v);\n    if (!m.matches()) return false;\n    String suffix = m.group(2);\n    return suffix.isEmpty() || Set.of(\"ns\",\"us\",\"ms\",\"s\",\"m\",\"h\",\"d\").contains(suffix.toLowerCase());\n}","tryCatchPattern":"try {\n    return DurationStyle.SIMPLE.parse(value, unit);\n} catch (IllegalArgumentException e) {\n    // fall back to a default duration or log\n    return Duration.ofMillis(defaultMillis);\n}","preventionTips":["Use only supported suffixes: ns, us, ms, s, m, h, d.","Omit the suffix to use the default unit (milliseconds).","Validate duration strings at config-load time."],"tags":["converter","duration","configuration"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}