apache/flink · error · IllegalArgumentException

Id must not be null.

Error message

Id must not be null.

What it means

Thrown by the copy constructor AbstractID(AbstractID id) when the argument is null. AbstractID is the base of Flink's JobID/AbstractID identifiers, and the copy constructor refuses to copy from nothing rather than producing a zeroed ID. It is a guard against programming errors at the call site.

Source

Thrown at flink-core/src/main/java/org/apache/flink/util/AbstractID.java:79

    /**
     * Constructs a new abstract ID.
     *
     * @param lowerPart the lower bytes of the ID
     * @param upperPart the higher bytes of the ID
     */
    public AbstractID(long lowerPart, long upperPart) {
        this.lowerPart = lowerPart;
        this.upperPart = upperPart;
    }

    /**
     * Copy constructor: Creates a new abstract ID from the given one.
     *
     * @param id the abstract ID to copy
     */
    public AbstractID(AbstractID id) {
        if (id == null) {
            throw new IllegalArgumentException("Id must not be null.");
        }
        this.lowerPart = id.lowerPart;
        this.upperPart = id.upperPart;
    }

    /** Constructs a new random ID from a uniform distribution. */
    public AbstractID() {
        ThreadLocalRandom random = ThreadLocalRandom.current();
        this.lowerPart = random.nextLong();
        this.upperPart = random.nextLong();
    }

    // --------------------------------------------------------------------------------------------

    /**
     * Gets the lower 64 bits of the ID.
     *
     * @return The lower 64 bits of the ID.

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Null-check the source ID before calling the copy constructor and fail with a meaningful message at the correct layer
  2. Trace where the null ID originates (map lookup, deserialization) and fix that producer
  3. If an absent ID is legitimate, create a fresh random AbstractID() instead of copying null

Example fix

// before
AbstractID copy = new AbstractID(someRegistry.get(jobName)); // may be null

// after
AbstractID original = someRegistry.get(jobName);
if (original == null) {
    throw new IllegalArgumentException("No ID registered for job " + jobName);
}
AbstractID copy = new AbstractID(original);
Defensive patterns

Strategy: validation

Validate before calling

if (sourceId == null) {
    throw new IllegalArgumentException("Source AbstractID must not be null");
}
AbstractID copy = new AbstractID(sourceId);

Try / catch

catch (IllegalArgumentException e) only if a null ID can legitimately reach legacy call sites; otherwise fail fast at the producer and do not catch.

Prevention

When it happens

Trigger: Calling `new AbstractID((AbstractID) null)` directly, or passing a variable that is null (e.g. an uninitialized JobGraph field, a lookup that returned null) to the copy constructor. Subclasses like JobID inherit the same constructor (`new JobID(nullJobID)`).

Common situations: Copying a JobID from a map/registry that did not contain the key; deserializing a request where the ID field was omitted; refactoring that leaves an ID unset in a test fixture.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/4ab8cfbffb237991. Report an issue: GitHub.