apache/flink · warning · IllegalStateException

Corrupt artifact fetching state.

Error message

Corrupt artifact fetching state.

What it means

An internal defensive guard thrown when fetchArtifacts(String[] uris) ends up with zero artifacts after the stream pipeline, despite the precondition requiring at least one URI. The comment 'Should not happen' indicates this is an unreachable-state assertion. It signals a logic bug in the artifact fetching pipeline rather than a user error.

Source

Thrown at flink-clients/src/main/java/org/apache/flink/client/program/artifact/ArtifactFetchManager.java:107

     */
    public Result fetchArtifacts(String[] uris) {
        checkArgument(uris != null && uris.length > 0, "At least one URI is required.");

        List<File> artifacts =
                Arrays.stream(uris)
                        .map(FunctionUtils.uncheckedFunction(this::fetchArtifact))
                        .collect(Collectors.toList());

        if (artifacts.size() > 1) {
            return new Result(null, artifacts);
        }

        if (artifacts.size() == 1) {
            return new Result(artifacts.get(0), null);
        }

        // Should not happen.
        throw new IllegalStateException("Corrupt artifact fetching state.");
    }

    /**
     * Fetches the job jar and any additional artifact if the given list is not null or empty.
     *
     * @param jobUri URI of the job jar
     * @param additionalUris URI(s) of any additional artifact to fetch
     * @return result with the fetched artifacts
     * @throws Exception
     */
    public Result fetchArtifacts(@Nullable String jobUri, @Nullable List<String> additionalUris)
            throws Exception {
        File jobJar = jobUri == null ? null : fetchArtifact(jobUri);
        List<File> additionalArtifacts =
                additionalUris == null
                        ? Collections.emptyList()
                        : additionalUris.stream()
                                .map(FunctionUtils.uncheckedFunction(this::fetchArtifact))

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Report this as a Flink bug — the state should be unreachable given the preconditions.
  2. Check if a custom ArtifactFetcher or FunctionUtils.uncheckedFunction wrapper is silently dropping exceptions.
  3. Verify the uris array is not being modified concurrently.
  4. Inspect the logs for any swallowed exceptions during fetchArtifact calls.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    Result result = fetchManager.fetchArtifacts(uris);
} catch (IllegalStateException e) {
    if (e.getMessage().contains("Corrupt artifact fetching state")) {
        // report as Flink bug; this state should be unreachable
    }
    throw e;
}

Prevention

When it happens

Trigger: Theoretically unreachable: the method checks uris.length > 0, maps each to a File, and the collect should always produce at least one result. Firing would indicate the stream pipeline silently dropped an element (e.g., a filter or exception was swallowed).

Common situations: This should not occur in practice. If it does, it points to a bug in fetchArtifact returning null (despite its signature) or a custom Collector dropping elements.

Related errors


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