quarkusio/quarkus · error · IllegalArgumentException

Flags are empty

Error message

Flags are empty

What it means

ApplicationModel.getDependenciesWithAnyFlag(int... flags) requires at least one dependency flag because it combines the flags with bitwise OR; with zero flags the combined value would be meaningless. It throws IllegalArgumentException('Flags are empty') to fail fast on a programming mistake by the caller.

Source

Thrown at independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/model/ApplicationModel.java:61

    Iterable<ResolvedDependency> getDependencies(int flags);

    /**
     * Returns application dependencies that have any of the flags combined in the value of the {@code flags} arguments set.
     *
     * @param flags dependency flags to match
     * @return application dependencies that matched the flags
     */
    Iterable<ResolvedDependency> getDependenciesWithAnyFlag(int flags);

    /**
     * Returns application dependencies that have any of the flags passed in as arguments set.
     *
     * @param flags dependency flags to match
     * @return application dependencies that matched the flags
     */
    default Iterable<ResolvedDependency> getDependenciesWithAnyFlag(int... flags) {
        if (flags.length == 0) {
            throw new IllegalArgumentException("Flags are empty");
        }
        int combined = flags[0];
        for (int i = 1; i < flags.length; ++i) {
            combined |= flags[i];
        }
        return getDependenciesWithAnyFlag(combined);
    }

    /**
     * Runtime dependencies of an application
     *
     * @return runtime dependencies of an application
     */
    Collection<ResolvedDependency> getRuntimeDependencies();

    /**
     * Quarkus platforms (BOMs) found in the configuration of an application
     *

View on GitHub (pinned to e1c734241f)

Solutions

  1. Pass at least one DependencyFlags-derived constant, e.g. getDependenciesWithAnyFlag(DependencyFlags.RESTARTABLE).
  2. Guard the call site: if flags.length == 0 return List.of() or skip the query instead of calling.
  3. Check where the flags array is constructed and ensure it is seeded with a default flag.

Example fix

// before
int[] flags = collectFlags(); // may be empty
var deps = model.getDependenciesWithAnyFlag(flags);
// after
int[] flags = collectFlags();
var deps = flags.length == 0
        ? List.<ResolvedDependency>of()
        : model.getDependenciesWithAnyFlag(flags);
Defensive patterns

Strategy: validation

Validate before calling

if (flags == null || flags.length == 0) {
    throw new IllegalArgumentException("At least one dependency flag required");
}
Iterable<ResolvedDependency> deps = model.getDependenciesWithAnyFlag(flags);

Type guard

static boolean hasFlags(int... flags) {
    return flags != null && flags.length > 0;
}

Try / catch

try {
    return model.getDependenciesWithAnyFlag(flags);
} catch (IllegalArgumentException e) {
    if ("Flags are empty".equals(e.getMessage())) {
        return List.of();
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling getDependenciesWithAnyFlag() with a zero-length int array, e.g. passing a dynamically built flag array that ended up empty, or AppModel metrics/capability queries built from an empty set of flags.

Common situations: Building flag arrays from user config or a Set<DependencyFlags> that was empty at call time; refactors where a constant flag was removed leaving an empty varargs call.

Related errors


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