prestodb/presto · error · PrestoException

INVALID_ARGUMENTS

INVALID_ARGUMENTS

Error message

Cannot register factories after filters are loaded.

What it means

ClientRequestFilterManager.registerClientRequestFilterFactory was called after filters were already loaded; registration is only allowed during plugin setup before the first filter use, so this late registration is rejected.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/ClientRequestFilterManager.java:46

import static com.facebook.presto.spi.StandardErrorCode.ALREADY_EXISTS;
import static com.facebook.presto.spi.StandardErrorCode.CONFIGURATION_INVALID;
import static com.facebook.presto.spi.StandardErrorCode.INVALID_ARGUMENTS;
import static com.google.common.collect.ImmutableList.toImmutableList;

@ThreadSafe
public class ClientRequestFilterManager
{
    private Map<String, ClientRequestFilterFactory> factories = new ConcurrentHashMap<>();

    @GuardedBy("this")
    private volatile List<ClientRequestFilter> filters = ImmutableList.of();
    private final AtomicBoolean loaded = new AtomicBoolean();

    public void registerClientRequestFilterFactory(ClientRequestFilterFactory factory)
    {
        if (loaded.get()) {
            throw new PrestoException(INVALID_ARGUMENTS, "Cannot register factories after filters are loaded.");
        }

        String name = factory.getName();
        if (factories.putIfAbsent(name, factory) != null) {
            throw new PrestoException(ALREADY_EXISTS, "A factory with the name '" + name + "' is already registered.");
        }
    }

    public void loadClientRequestFilters()
    {
        if (!loaded.compareAndSet(false, true)) {
            throw new PrestoException(CONFIGURATION_INVALID, "loadClientRequestFilters can only be called once.");
        }

        filters = factories.values().stream()
                .map(factory -> factory.create())
                .collect(toImmutableList());
        factories = null;

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Register client request filter factories from the plugin's create() method, before any request is served
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-main-base/src/main/java/com/facebook/presto/ClientRequestFilterManager.java:46 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/16492b31ba948df2. Report an issue: GitHub.