quarkusio/quarkus · error · IllegalStateException

Invalid () expression on:

Error message

Invalid () expression on: 

What it means

A @Scheduled member (cron, every, delayed, or overdue grace period) given as a value or config expression could not be parsed into a Duration/Schedule by DurationConverter. The member name is embedded in the message and the original parse exception is chained as the cause.

Source

Thrown at extensions/scheduler/common/src/main/java/io/quarkus/scheduler/common/runtime/util/SchedulerUtils.java:189

            return false;
        }
        int exprStart = val.indexOf("${");
        int exprEnd = -1;
        if (exprStart >= 0) {
            exprEnd = val.indexOf('}', exprStart + 2);
        }
        return exprEnd > 0;
    }

    private static long parseDurationAsMillis(Scheduled scheduled, String value, String memberName) {
        return Math.abs(parseDuration(scheduled, value, memberName).toMillis());
    }

    private static Duration parseDuration(Scheduled scheduled, String value, String memberName) {
        try {
            return DurationConverter.parseDuration(value);
        } catch (Exception e) {
            throw new IllegalStateException("Invalid " + memberName + "() expression on: " + scheduled, e);
        }
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Use a valid duration string with unit, e.g. "10s", "5m", "1h" or ISO-8601 like "PT10S"
  2. Fix the config value the expression resolves to
  3. Check the chained cause exception for the exact parse failure
  4. For cron use a valid cron expression via @Scheduled(cron=...) instead of duration syntax

Example fix

// before
@Scheduled(every = "10")
// after
@Scheduled(every = "10s")
Defensive patterns

Strategy: validation

Validate before calling

try {
    java.time.Duration.parse("10s".matches(".*[a-zA-Z].*") ? "PT" + "10s".toUpperCase() : "PT" + "10s" + "S");
} catch (Exception e) { /* invalid duration */ }

Try / catch

try { DurationConverter.parseDuration(value); }
catch (Exception e) { throw new IllegalArgumentException("Bad duration: " + value, e); }

Prevention

When it happens

Trigger: Calling SchedulerUtils.parseOverdueGracePeriod or parseDurationAsMillis with an @Scheduled whose member value is not a valid duration (e.g. "10", "ten seconds", an unexpanded/bad expression).

Common situations: Writing every="10" without a time unit ("10s"); misspelled unit ("5min" vs "5m"); config expression resolving to empty or malformed string; negative or nonsense durations.

Understand the failure class

Background: "invalid duration" / "failed to parse duration": why your timeout, interval, or TTL string is rejected and which formats each library accepts — this error's family across 32 libraries.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/c3a27a6a869cc853. Report an issue: GitHub.