{"id":"42324cf4e227631a","repo":"junit-team/junit5","slug":"timeout-duration-is-not-in-the-expected-format-n","errorCode":null,"errorMessage":"Timeout duration is not in the expected format (<number> [ns|μs|ms|s|m|h|d])","messagePattern":"Timeout duration is not in the expected format \\(<number> \\[ns\\|μs\\|ms\\|s\\|m\\|h\\|d\\]\\)","errorType":"exception","errorClass":"DateTimeParseException","httpStatus":null,"severity":"warning","filePath":"junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TimeoutDurationParser.java","lineNumber":58,"sourceCode":"\t\t\"ns\", NANOSECONDS, //\n\t\t\"μs\", MICROSECONDS, //\n\t\t\"ms\", MILLISECONDS, //\n\t\t\"s\", SECONDS, //\n\t\t\"m\", MINUTES, //\n\t\t\"h\", HOURS, //\n\t\t\"d\", DAYS //\n\t);\n\n\tTimeoutDuration parse(CharSequence text) throws DateTimeParseException {\n\t\tMatcher matcher = PATTERN.matcher(text);\n\t\tif (matcher.matches()) {\n\t\t\tlong value = Long.parseLong(matcher.group(1));\n\t\t\tString unitAbbreviation = matcher.group(2);\n\t\t\tTimeUnit unit = unitAbbreviation == null ? SECONDS\n\t\t\t\t\t: requireNonNull(UNITS_BY_ABBREVIATION.get(unitAbbreviation.toLowerCase(Locale.ENGLISH)));\n\t\t\treturn new TimeoutDuration(value, unit);\n\t\t}\n\t\tthrow new DateTimeParseException(\"Timeout duration is not in the expected format (<number> [ns|μs|ms|s|m|h|d])\",\n\t\t\ttext, 0);\n\t}\n\n}\n","sourceCodeStart":40,"sourceCodeEnd":63,"githubUrl":"https://github.com/junit-team/junit5/blob/956246301e03d757539f7b76dd5a91f298637563/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TimeoutDurationParser.java#L40-L63","documentation":"Thrown by TimeoutDurationParser.parse() when the supplied text does not match the expected pattern '([1-9]\\d*) ?((?:[nμm]?s)|m|h|d)?' (case-insensitive, unicode-aware). The format is a positive integer optionally followed by a unit abbreviation (ns, μs, ms, s, m, h, d); seconds is the default when no unit is given. Note: when used via TimeoutConfiguration for config parameters, this exception is caught and logged as a warning with the timeout ignored, so it does not surface as a test failure in that path.","triggerScenarios":"Calling TimeoutDurationParser.parse(CharSequence) with a string that fails the regex: zero ('0s'), negative ('-5s'), decimal ('1.5s'), unsupported unit ('5min'), trailing characters ('5 seconds'), or a value starting with 0. This is invoked when parsing junit.jupiter.execution.timeout.* configuration parameter values.","commonSituations":"Setting junit.jupiter.execution.timeout.testable.method or junit.jupiter.execution.timeout.default in junit-platform.properties with a typo, wrong unit abbreviation (e.g., 'min' instead of 'm', 'sec' instead of 's'), or a zero/decimal value. The value is silently ignored and a warning is logged, so timeouts silently don't apply.","solutions":["Use one of the supported unit abbreviations: ns, μs, ms, s, m, h, d — e.g., '500ms' not '500millis'","Ensure the value is a positive integer (regex requires [1-9]\\d*), so '0' and decimals are invalid","Check the log output for the 'Ignored invalid timeout' warning to confirm the parser rejected your value","Omit the unit entirely to default to seconds (e.g., '30' means 30 seconds)"],"exampleFix":"# before (in junit-platform.properties)\njunit.jupiter.execution.timeout.default = 500millis\n\n# after\njunit.jupiter.execution.timeout.default = 500ms","handlingStrategy":"validation","validationCode":"// Validate a timeout config string before relying on it\nString timeout = \"500ms\";\nPattern p = Pattern.compile(\"([1-9]\\\\d*) ?((?:[nμm]?s)|m|h|d)?\",\n    Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);\nif (!p.matcher(timeout).matches()) {\n    throw new IllegalArgumentException(\n        \"Invalid timeout format: \" + timeout + \". Expected: <number> [ns|μs|ms|s|m|h|d]\");\n}\nSet<String> validUnits = Set.of(\"ns\", \"μs\", \"ms\", \"s\", \"m\", \"h\", \"d\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Double-check timeout values in junit-platform.properties against the allowed units: ns, μs, ms, s, m, h, d","Remember the value must be a positive integer (no leading zero, no decimals)","Watch for log warnings containing 'Ignored invalid timeout' — they indicate the parser rejected your value silently"],"tags":["timeout","configuration","format-error","junit-jupiter-engine"],"analyzedSha":"956246301e03d757539f7b76dd5a91f298637563","analyzedAt":"2026-08-04T19:25:17.049Z","schemaVersion":2}