apache/seatunnel · error · java.lang.IllegalArgumentException

Could not parse duration value

Error message

Could not parse duration value '%s'. Supported formats: shorthand (e.g. 10S, 500MS) or ISO-8601 (e.g. PT10S).

What it means

Thrown from ConfigUtil.convertToDuration when the trimmed value is non-empty but matches neither the shorthand format (e.g. 10S, 500MS, 5M) nor ISO-8601 (e.g. PT10S): the shorthand parser returned null and the ISO-8601 parse also failed. It fires on malformed duration strings like "ten seconds", "10 sec", or a bare "10" with no unit, indicating the user's duration syntax is unsupported rather than blank.

Solutions

  1. Write the value in shorthand form with a unit suffix, e.g. 10S, 500MS, 5M, 1H
  2. Or use ISO-8601 form, e.g. PT10S, PT1M30S
  3. Remember a bare number without a unit is invalid — always append a time unit
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at seatunnel-api/src/main/java/org/apache/seatunnel/api/configuration/util/ConfigUtil.java:203 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/0def5ecea3e33dd0. Report an issue: GitHub.

Appendix: source

Thrown at seatunnel-api/src/main/java/org/apache/seatunnel/api/configuration/util/ConfigUtil.java:203

        }

        String value = o.toString().trim();
        if (value.isEmpty()) {
            throw new IllegalArgumentException("Duration value cannot be blank.");
        }

        // Prefer shorthand format first to match connector docs, e.g. 10S / 500MS.
        String normalized = value.replaceAll("\\s+", "").toUpperCase(Locale.ROOT);
        Duration shorthandDuration = tryParseShorthandDuration(normalized);
        if (shorthandDuration != null) {
            return shorthandDuration;
        }

        // Fallback to ISO-8601 duration format, e.g. PT10S.
        try {
            return Duration.parse(value);
        } catch (Exception e) {
            throw new IllegalArgumentException(
                    String.format(
                            "Could not parse duration value '%s'. Supported formats: shorthand (e.g. 10S, 500MS) or ISO-8601 (e.g. PT10S).",
                            value),
                    e);
        }
    }

    private static Duration tryParseShorthandDuration(String normalizedValue) {
        Duration parsed = parseDurationWithSuffix(normalizedValue, "MS", Duration::ofMillis);
        if (parsed != null) {
            return parsed;
        }
        parsed = parseDurationWithSuffix(normalizedValue, "S", Duration::ofSeconds);
        if (parsed != null) {
            return parsed;
        }
        parsed = parseDurationWithSuffix(normalizedValue, "M", Duration::ofMinutes);
        if (parsed != null) {

View on GitHub (pinned to cf67b549a7)