{"record":{"id":"c513c69feb770256","repo":"apache/pulsar","slug":"no-dependencies-are-registered-for-function-fid","errorCode":null,"errorMessage":"No dependencies are registered for function ${fid}","messagePattern":"No dependencies are registered for function (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheManagerImpl.java","lineNumber":58,"sourceCode":"    public FunctionCacheManagerImpl(ClassLoader rootClassLoader) {\n        this.cacheFunctions = new ConcurrentHashMap<>();\n        this.rootClassLoader = rootClassLoader;\n    }\n\n    Map<String, FunctionCacheEntry> getCacheFunctions() {\n        return cacheFunctions;\n    }\n\n    @Override\n    public ClassLoader getClassLoader(String fid) {\n        if (fid == null) {\n            throw new IllegalArgumentException(\"FunctionID not set\");\n        }\n\n        synchronized (cacheFunctions) {\n            FunctionCacheEntry entry = cacheFunctions.get(fid);\n            if (entry == null) {\n                throw new IllegalStateException(\"No dependencies are registered for function \" + fid);\n            }\n            return entry.getClassLoader();\n        }\n    }\n\n    @Override\n    public void registerFunctionInstance(String fid,\n                                         String eid,\n                                         List<String> requiredJarFiles,\n                                         List<URL> requiredClasspaths)\n            throws IOException {\n        if (fid == null) {\n            throw new NullPointerException(\"FunctionID not set\");\n        }\n\n        synchronized (cacheFunctions) {\n            FunctionCacheEntry entry = cacheFunctions.get(fid);\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheManagerImpl.java#L40-L76","documentation":"FunctionCacheManagerImpl.getClassLoader(fid) looks up the FunctionCacheEntry for the given function ID; this IllegalStateException is thrown when no entry exists — i.e. no jar dependencies were ever registered for that function ID on this worker, so there is no classloader to return.","triggerScenarios":"Calling getClassLoader(fid) for a fid that was never passed to registerFunctionInstance/registerFunctionInstanceWithArchive, or after the entry was removed by removeFunction / cache eviction while the instance is still running.","commonSituations":"A worker restarted and its in-memory function cache is empty while old function instances still request classloaders; ordering bug where the classloader is fetched before registering dependencies; function was deleted/updated concurrently and the cache entry was removed; fid mismatch (typo or different ID format) between registration and lookup.","solutions":["Register the function's dependencies first via registerFunctionInstance(...) / registerFunctionInstanceWithArchive(...) before requesting the classloader.","Restart the affected function instance so it re-registers with the manager after a worker restart.","Verify the fid used for lookup matches the one used at registration (no typo/normalization differences)."],"exampleFix":"// before\nClassLoader cl = cacheManager.getClassLoader(fid); // nothing registered yet\n// after\nFunctionCacheEntry entry = cacheManager.getFunctionCacheEntry(tenant, namespace, name, null, null, null, null, null, null, false, null);\ncacheManager.registerFunctionInstance(fid, entry, jarFiles, classpaths, eid, ...);\nClassLoader cl = cacheManager.getClassLoader(fid);","handlingStrategy":"try-catch","validationCode":"FunctionCacheEntry entry = cacheManager.getFunctionCacheEntry(tenant, namespace, name);\nif (entry == null) {\n    // register dependencies before calling getClassLoader\n    cacheManager.registerFunctionInstance(fid, entry, jarFiles, classpaths, eid, null, null, null, 0L, null);\n}","typeGuard":null,"tryCatchPattern":"try {\n    ClassLoader cl = cacheManager.getClassLoader(fid);\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"No dependencies are registered\")) {\n        // re-register dependencies (e.g. after worker restart) then retry once\n        registerDependencies(fid);\n        ClassLoader cl = cacheManager.getClassLoader(fid);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Always register jar dependencies before requesting a classloader.","On worker restart, restart all function instances so they re-register their dependencies.","Log and match the fid used at registration vs lookup to catch ID mismatches."],"tags":["pulsar-functions","function-cache","classloader","state"],"backgroundTag":"resource-not-registered","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}