gradle/gradle · error · IllegalStateException

Providers passed to attributeProvider(Attribute, Provider) m

Error message

Providers passed to attributeProvider(Attribute, Provider) must always be present when queried.

What it means

Gradle throws this error when the following condition is violated: Providers passed to attributeProvider(Attribute, Provider) must always be present when queried.

Source

Thrown at platforms/core-configuration/model-core/src/main/java/org/gradle/api/internal/provider/DelegatingProviderWithValue.java:47

 * the provider's value when calling {@link #calculatePresence(ValueConsumer)}, and therefore
 * avoid eagerly realizing that value before it is actually needed.
 */
public class DelegatingProviderWithValue<T> extends AbstractProviderWithValue<T> {

    private final ProviderInternal<T> delegate;
    private final String nonPresentMessage;

    public DelegatingProviderWithValue(ProviderInternal<T> delegate, String nonPresentMessage) {
        this.delegate = delegate;
        this.nonPresentMessage = nonPresentMessage;
    }

    @Override
    protected Value<? extends T> calculateOwnValue(ValueConsumer consumer) {
        try (EvaluationScopeContext ignored = openScope()) {
            Value<? extends T> value = delegate.calculateValue(consumer);
            if (value.isMissing()) {
                throw new IllegalStateException(nonPresentMessage);
            }
            return value;
        } catch (Exception e) {
            throw UncheckedException.throwAsUncheckedException(e);
        }
    }

    @Nullable
    @Override
    public Class<T> getType() {
        return delegate.getType();
    }

}

View on GitHub (pinned to 534f27719b)

Solutions

  1. Review the values passed to this API and correct the invalid input described in the error message.

When it happens

Trigger: Thrown at platforms/core-configuration/model-core/src/main/java/org/gradle/api/internal/provider/DelegatingProviderWithValue.java:47 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22). Data as JSON: /api/errors/0e1adbcad62dba0a. Report an issue: GitHub.