apache/pulsar · error · RestException
Error caching authentication data for %s %s:- %s
Error message
Error caching authentication data for %s %s:- %s
What it means
When worker authentication is enabled and the runtime factory provides a FunctionAuthProvider, registerSource tries to cache the client's authentication data for the source. If cacheAuthData throws, the worker returns 500 INTERNAL_SERVER_ERROR with 'Error caching authentication data for <ComponentType> <sourceName>:- <reason>'. This is a server-side failure while preparing per-function credentials for the runtime, not a problem with the source config itself.
Source
Thrown at pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SourcesImpl.java:226
try {
Optional<FunctionAuthData> functionAuthData = functionAuthProvider
.cacheAuthData(finalFunctionDetails,
authParams.getClientAuthenticationDataSource());
functionAuthData.ifPresent(authData ->
functionMetaDataObj.setFunctionAuthSpec()
.setData(authData.getData()));
} catch (Exception e) {
log.error().attr("componentType", ComponentTypeUtils.toString(componentType))
.attr("tenant", tenant).attr("namespace", namespace)
.attr("componentName", sourceName).exception(e)
.log("Error caching authentication data for / /");
throw new RestException(Response.Status.INTERNAL_SERVER_ERROR,
String.format("Error caching authentication data for %s %s:- %s",
ComponentTypeUtils.toString(componentType), sourceName, e.getMessage()));
}
}
});
}
PackageLocationMetaData packageLocationMetaData;
try {
packageLocationMetaData = getFunctionPackageLocation(functionMetaDataObj,
sourcePkgUrl, fileDetail, componentPackageFile);
} catch (Exception e) {
log.error().attr("componentType", ComponentTypeUtils.toString(componentType)).attr("tenant", tenant)
.attr("namespace", namespace).attr("componentName", sourceName).exception(e)
.log("Failed process / / package");
throw new RestException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());View on GitHub (pinned to 820761864e)
Solutions
- Check the worker log entry 'Error caching authentication data for / /' for the full underlying stack trace.
- Verify the client authentication plugin configured for the CLI/API call is valid and its data source can be serialized by the runtime auth provider.
- Review the FunctionAuthProvider implementation configured in the worker (getAuthProvider) for bugs or incompatible versions.
- If auth data caching is unnecessary for the deployment, either disable worker authentication or use a runtime factory without a function auth provider.
Example fix
// before: worker conf pointing at an incompatible/absent auth provider functionAuthProviderClassName: com.example.BrokenFunctionAuthProvider // after: use the shipped provider for the configured runtime functionAuthProviderClassName: org.apache.pulsar.functions.auth.KubernetesFunctionAuthProvider
Defensive patterns
Strategy: try-catch
Validate before calling
// Before registering, confirm the client auth data source is usable
if (authParams != null && authParams.getClientAuthenticationDataSource() != null) {
Objects.requireNonNull(authParams.getClientAuthenticationDataSource(), "auth data source must not be null");
} Try / catch
try {
admin.sources().createSource(cfg, pkgUrl, archive);
} catch (PulsarAdminException e) {
if (e.getStatusCode() == 500 && e.getMessage() != null && e.getMessage().startsWith("Error caching authentication data")) {
// inspect worker logs; fix client auth plugin or worker auth provider, then retry
} else {
throw e;
}
} Prevention
- Use the officially shipped FunctionAuthProvider matching your runtime factory (Kubernetes/Process/Thread).
- Keep client and server auth plugin versions aligned.
- Confirm the worker's authenticationEnabled setting matches your intended deployment; don't enable it without a working auth provider.
When it happens
Trigger: registerSource with worker authenticationEnabled=true and a runtime factory auth provider whose cacheAuthData(clientAuthenticationDataSource) throws — e.g. serialization failure of auth data, backend store unavailable, or a misconfigured auth provider.
Common situations: Client passing an authentication data source the provider cannot serialize; Kubernetes runtime factory auth plugin failing to write secrets; auth plugin version mismatch between worker config and expected interface; auth backend (e.g. a state store) down.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Error caching authentication data for %s %s:- %s
- Error caching authentication data for %s %s:- %s
- e
- Invalid combination of Original principal cannot be empty if
- Need to authenticate to perform the request
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/f70b5cbf33cd08b7.
Report an issue: GitHub.