{"record":{"id":"76f7d810ae1b151b","repo":"conductor-oss/conductor","slug":"not-valid-duration-s","errorCode":null,"errorMessage":"Not valid duration: %s","messagePattern":"Not valid duration: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/netflix/conductor/core/utils/DateTimeUtils.java","lineNumber":39,"sourceCode":"import org.apache.commons.lang3.time.DateUtils;\n\npublic class DateTimeUtils {\n\n    private static final String[] DATE_PATTERNS =\n            new String[] {\"yyyy-MM-dd HH:mm\", \"yyyy-MM-dd HH:mm z\", \"yyyy-MM-dd\"};\n    private static final Pattern DURATION_PATTERN =\n            Pattern.compile(\n                    \"\"\"\n                    \\\\s*(?:(\\\\d+)\\\\s*(?:days?|d))?\\\n                    \\\\s*(?:(\\\\d+)\\\\s*(?:hours?|hrs?|h))?\\\n                    \\\\s*(?:(\\\\d+)\\\\s*(?:minutes?|mins?|m))?\\\n                    \\\\s*(?:(\\\\d+)\\\\s*(?:seconds?|secs?|s))?\\\n                    \\\\s*\"\"\",\n                    Pattern.CASE_INSENSITIVE);\n\n    public static Duration parseDuration(String text) {\n        Matcher m = DURATION_PATTERN.matcher(text);\n        if (!m.matches()) throw new IllegalArgumentException(\"Not valid duration: \" + text);\n\n        int days = (m.start(1) == -1 ? 0 : Integer.parseInt(m.group(1)));\n        int hours = (m.start(2) == -1 ? 0 : Integer.parseInt(m.group(2)));\n        int mins = (m.start(3) == -1 ? 0 : Integer.parseInt(m.group(3)));\n        int secs = (m.start(4) == -1 ? 0 : Integer.parseInt(m.group(4)));\n        return Duration.ofSeconds((days * 86400) + (hours * 60L + mins) * 60L + secs);\n    }\n\n    public static Date parseDate(String date) throws ParseException {\n        return DateUtils.parseDate(date, DATE_PATTERNS);\n    }\n}\n","sourceCodeStart":21,"sourceCodeEnd":52,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/core/src/main/java/com/netflix/conductor/core/utils/DateTimeUtils.java#L21-L52","documentation":"Thrown by DateTimeUtils.parseDuration when the input string does not match the expected duration pattern. The pattern accepts combinations of days (d/days), hours (h/hrs/hours), minutes (m/mins/minutes), and seconds (s/secs/seconds), case-insensitive, with optional whitespace. Any string that doesn't conform — including ISO-8601 durations like 'PT5M' or values with units like milliseconds/weeks — will be rejected.","triggerScenarios":"Passing a duration string to parseDuration that doesn't match the regex: e.g. 'PT5M' (ISO-8601), '1 week', '500ms', '12:30', or a completely malformed string. This method is called when parsing duration-type configuration properties and workflow timeout values.","commonSituations":"Using ISO-8601 duration format (PT1H30M) where Conductor expects its own shorthand format (1h30m). Typing 'ms' or 'millisecond' which the pattern doesn't support (minimum unit is seconds). Including unsupported units like 'weeks' or 'years'. Passing a numeric-only string like '60' without a unit suffix.","solutions":["Use the supported duration shorthand format: days (d), hours (h), minutes (m), seconds (s) — e.g. '1h30m' or '2 days 4 hours'.","Convert ISO-8601 durations to the supported format (e.g. 'PT5M' becomes '5m').","Ensure the string includes at least one valid unit suffix — bare numbers are not accepted.","Remove unsupported units (milliseconds, microseconds, weeks, months, years) from the duration string."],"exampleFix":"// before\nDateTimeUtils.parseDuration(\"PT1H30M\")  // throws\nDateTimeUtils.parseDuration(\"500ms\")       // throws\n\n// after\nDateTimeUtils.parseDuration(\"1h30m\")      // ok\nDateTimeUtils.parseDuration(\"90m\")         // ok","handlingStrategy":"validation","validationCode":"// Validate duration string format before calling parseDuration\nprivate static final Pattern DURATION_PATTERN = Pattern.compile(\n    \"\\\\s*(?:(\\\\d+)\\\\s*(?:days?|d))?\"\n    + \"\\\\s*(?:(\\\\d+)\\\\s*(?:hours?|hrs?|h))?\"\n    + \"\\\\s*(?:(\\\\d+)\\\\s*(?:minutes?|mins?|m))?\"\n    + \"\\\\s*(?:(\\\\d+)\\\\s*(?:seconds?|secs?|s))?\"\n    + \"\\\\s*\", Pattern.CASE_INSENSITIVE);\n\nif (!DURATION_PATTERN.matcher(durationStr).matches()) {\n    throw new IllegalArgumentException(\n        \"Invalid duration format: '\" + durationStr\n            + \"'. Use format like '1h30m', '2 days', '45s'.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    Duration d = DateTimeUtils.parseDuration(text);\n} catch (IllegalArgumentException e) {\n    // Provide a helpful message with the accepted format\n    throw new IllegalArgumentException(\n        \"Duration '\" + text + \"' is invalid. Supported: days(d), hours(h), minutes(m), seconds(s).\"\n            + \" Example: '1h30m'.\", e);\n}","preventionTips":["Use Conductor's shorthand format (d/h/m/s) for durations, not ISO-8601 (PT...).","Always include a unit suffix — bare numbers are rejected.","Document the accepted format in client SDKs and configuration guides."],"tags":["duration","parsing","configuration","date-time"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}