apache/pulsar · error · IllegalArgumentException

FunctionID not set

Error message

FunctionID not set

What it means

FunctionCacheManagerImpl.getClassLoader(fid) resolves a function's cached classloader by function ID. This IllegalArgumentException is thrown when fid is null, because a null function ID can never map to a cache entry and indicates a caller bug (missing function metadata) rather than a cache miss.

Source

Thrown at pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheManagerImpl.java:52

    /** Registered Functions. **/
    private final Map<String, FunctionCacheEntry> cacheFunctions;

    private ClassLoader rootClassLoader;

    public FunctionCacheManagerImpl(ClassLoader rootClassLoader) {
        this.cacheFunctions = new ConcurrentHashMap<>();
        this.rootClassLoader = rootClassLoader;
    }

    Map<String, FunctionCacheEntry> getCacheFunctions() {
        return cacheFunctions;
    }

    @Override
    public ClassLoader getClassLoader(String fid) {
        if (fid == null) {
            throw new IllegalArgumentException("FunctionID not set");
        }

        synchronized (cacheFunctions) {
            FunctionCacheEntry entry = cacheFunctions.get(fid);
            if (entry == null) {
                throw new IllegalStateException("No dependencies are registered for function " + fid);
            }
            return entry.getClassLoader();
        }
    }

    @Override
    public void registerFunctionInstance(String fid,
                                         String eid,
                                         List<String> requiredJarFiles,
                                         List<URL> requiredClasspaths)
            throws IOException {
        if (fid == null) {

View on GitHub (pinned to 820761864e)

Solutions

  1. Ensure the function's FunctionMetaData is fully populated (non-null function ID) before initializing the instance runtime.
  2. Guard the call site: only call getClassLoader with a non-null fid obtained from getFunctionCacheEntry.
  3. Fix the code path that constructs the function details so the ID is never dropped.

Example fix

// before
ClassLoader cl = cacheManager.getClassLoader(functionDetails.getFunctionId()); // may be null
// after
String fid = functionDetails.getFunctionId();
Objects.requireNonNull(fid, "FunctionID not set");
ClassLoader cl = cacheManager.getClassLoader(fid);
Defensive patterns

Strategy: validation

Validate before calling

if (fid == null || fid.isEmpty()) {
    throw new IllegalArgumentException("Cannot get classloader: function ID missing from function metadata");
}

Try / catch

try {
    ClassLoader cl = cacheManager.getClassLoader(fid);
} catch (IllegalArgumentException e) {
    // function metadata incomplete — fail instance init with actionable message
    throw new IllegalStateException("Function ID was not set on FunctionMetaData; cannot load classloader", e);
}

Prevention

When it happens

Trigger: Calling getClassLoader(null) — typically because the function's FunctionMetaData/FunctionID was not populated before the instance requested its classloader, e.g. in JavaInstanceRunnable or the function instance runtime setup.

Common situations: Constructing a function instance with incomplete FunctionMetaData; custom code embedding the function runtime and forgetting to set the function ID; deserialization of function details that dropped the ID field.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/9e5300eddf624f50. Report an issue: GitHub.