{"record":{"id":"35e9954c295e882d","repo":"apache/dubbo","slug":"unknown-unit-chronounit","errorCode":null,"errorMessage":"Unknown unit ${chronoUnit}","messagePattern":"Unknown unit (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/convert/StringToDurationConverter.java","lineNumber":224,"sourceCode":"\n            public Duration parse(String value) {\n                return Duration.of(Long.parseLong(value), this.chronoUnit);\n            }\n\n            public long longValue(Duration value) {\n                return this.longValue.apply(value);\n            }\n\n            public static TimeUnit fromChronoUnit(ChronoUnit chronoUnit) {\n                if (chronoUnit == null) {\n                    return TimeUnit.MILLIS;\n                }\n                for (TimeUnit candidate : values()) {\n                    if (candidate.chronoUnit == chronoUnit) {\n                        return candidate;\n                    }\n                }\n                throw new IllegalArgumentException(\"Unknown unit \" + chronoUnit);\n            }\n\n            public static TimeUnit fromSuffix(String suffix) {\n                for (TimeUnit candidate : values()) {\n                    if (candidate.suffix.equalsIgnoreCase(suffix)) {\n                        return candidate;\n                    }\n                }\n                throw new IllegalArgumentException(\"Unknown unit '\" + suffix + \"'\");\n            }\n        }\n    }\n}\n","sourceCodeStart":206,"sourceCodeEnd":238,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/convert/StringToDurationConverter.java#L206-L238","documentation":"Thrown by DurationStyle.TimeUnit.fromChronoUnit(chronoUnit) when the passed ChronoUnit is not one of the supported units: NANOS, MICROS, MILLIS, SECONDS, MINUTES, HOURS, DAYS. The method maps a java.time.temporal.ChronoUnit to Dubbo's internal TimeUnit enum; unsupported ChronoUnit values (WEEKS, MONTHS, YEARS, etc.) cause this exception.","triggerScenarios":"Calling fromChronoUnit with ChronoUnit.WEEKS, ChronoUnit.MONTHS, ChronoUnit.YEARS, ChronoUnit.DECADES, ChronoUnit.CENTURIES, etc. Called internally by SIMPLE.parse when a default unit is supplied that is out of the supported set.","commonSituations":"A Dubbo API or extension that lets callers specify a default ChronoUnit for duration parsing, and the caller passes WEEKS or MONTHS. Rare in typical property configuration; more common in programmatic SPI usage.","solutions":["Use one of the supported ChronoUnit values: NANOS, MICROS, MILLIS, SECONDS, MINUTES, HOURS, or DAYS.","If you need weeks or months, convert the duration to days yourself before passing it to the duration converter.","Pass null for the unit to get the default (MILLIS)."],"exampleFix":"// before\nDuration d = DurationStyle.SIMPLE.parse(\"7\", ChronoUnit.WEEKS);\n\n// after\nDuration d = DurationStyle.SIMPLE.parse(\"7\", ChronoUnit.DAYS);","handlingStrategy":"validation","validationCode":"Set<ChronoUnit> supported = EnumSet.of(\n    ChronoUnit.NANOS, ChronoUnit.MICROS, ChronoUnit.MILLIS,\n    ChronoUnit.SECONDS, ChronoUnit.MINUTES, ChronoUnit.HOURS, ChronoUnit.DAYS);\nif (!supported.contains(chronoUnit)) {\n    // unsupported — pick a fallback or reject\n}","typeGuard":"static boolean isSupportedChronoUnit(ChronoUnit u) {\n    return u == ChronoUnit.NANOS || u == ChronoUnit.MICROS || u == ChronoUnit.MILLIS\n        || u == ChronoUnit.SECONDS || u == ChronoUnit.MINUTES\n        || u == ChronoUnit.HOURS || u == ChronoUnit.DAYS;\n}","tryCatchPattern":"try {\n    return TimeUnit.fromChronoUnit(chronoUnit);\n} catch (IllegalArgumentException e) {\n    return TimeUnit.MILLIS; // safe default\n}","preventionTips":["Only pass supported ChronoUnit values to fromChronoUnit.","Convert weeks/months/years to days manually before duration conversion.","Pass null to get the default (MILLIS)."],"tags":["converter","duration","time-unit","unsupported"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}