apache/pulsar · error · IllegalStateException
PulsarAdmin is not enabled in function worker
Error message
PulsarAdmin is not enabled in function worker
What it means
getPulsarAdmin() exposes a PulsarAdmin client to functions/connectors only when the worker explicitly enables it via exposePulsarAdminClientEnabled. When the flag is false (the safe default), any call throws IllegalStateException because the framework refuses to hand an admin client to untrusted user code.
Source
Thrown at pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/ContextImpl.java:378
public Map<String, Object> getUserConfigMap() {
return userConfigs;
}
@Override
public String getSecret(String secretName) {
if (secretsMap.containsKey(secretName)) {
return secretsProvider.provideSecret(secretName, secretsMap.get(secretName));
} else {
return null;
}
}
@Override
public PulsarAdmin getPulsarAdmin() {
if (exposePulsarAdminClientEnabled) {
return pulsarAdmin;
} else {
throw new IllegalStateException("PulsarAdmin is not enabled in function worker");
}
}
@Override
public <T extends StateStore> T getStateStore(String name) {
return getStateStore(
config.getFunctionDetails().getTenant(),
config.getFunctionDetails().getNamespace(),
name);
}
@SuppressWarnings("unchecked")
@Override
public <T extends StateStore> T getStateStore(String tenant, String ns, String name) {
return (T) stateManager.getStore(tenant, ns, name);
}
private void ensureStateEnabled() {View on GitHub (pinned to 820761864e)
Solutions
- Set `exposePulsarAdminClientEnabled=true` in the function worker's configuration and restart the workers.
- If enabling admin access is not acceptable, restructure the code to use the regular Pulsar client (context.getPulsarClient()) instead of admin operations.
- Check worker config actually took effect (correct conf file, no stale workers) after changing the flag.
Example fix
// before (worker config) exposePulsarAdminClientEnabled=false // after exposePulsarAdminClientEnabled=true
Defensive patterns
Strategy: validation
Validate before calling
// before calling getPulsarAdmin, confirm worker conf has:
// exposePulsarAdminClientEnabled=true
boolean adminEnabled = Boolean.getBoolean("pulsar.functions.exposePulsarAdminClientEnabled"); Try / catch
try { PulsarAdmin admin = context.getPulsarAdmin(); ... } catch (IllegalStateException e) { /* fall back to PulsarClient-only operations */ } Prevention
- Enable exposePulsarAdminClientEnabled in worker config before deploying connectors needing admin
- Document the requirement in connector deployment docs
- Prefer PulsarClient operations when admin APIs are not strictly needed
When it happens
Trigger: User code (function, source, sink) calls context.getPulsarAdmin() while the function worker has `exposePulsarAdminClientEnabled=false` (default) in its configuration.
Common situations: Connectors like the ElasticSearch sink that require an admin client deployed on a worker where the flag was never enabled; copying connector code into a function on a default-configured cluster.
Related errors
- Access to environment variable %s is not allowed.
- pulsarWebServiceUrl cannot be null
- Invalid broker configuration. Authentication must be enabled
- Issuer URL does not use https, but must:
- SHA-256 algorithm not found
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/79c8c6d2652bdc6a.
Report an issue: GitHub.