{"record":{"id":"704fdd8be5ced24f","repo":"apache/pulsar","slug":"java-lang-runtimeexception-wrapping-pulsaradminex","errorCode":null,"errorMessage":"java.lang.RuntimeException (wrapping PulsarAdminException from getStatus)","messagePattern":"java\\.lang\\.RuntimeException \\(wrapping PulsarAdminException from getStatus\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/ComponentImpl.java","lineNumber":256,"sourceCode":"                    if (workerInfo == null) {\n                        return emptyStatus(functionMetaData.getFunctionDetails().getParallelism());\n                    }\n\n                    if (uri == null) {\n                        throw new WebApplicationException(\n                                Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build());\n                    } else {\n                        URI redirect =\n                                UriBuilder.fromUri(uri).host(workerInfo.getWorkerHostname()).port(workerInfo.getPort())\n                                        .build();\n                        throw new WebApplicationException(Response.temporaryRedirect(redirect).build());\n                    }\n                }\n            } else {\n                try {\n                    return getStatus(tenant, namespace, name, assignments, uri);\n                } catch (PulsarAdminException e) {\n                    throw new RuntimeException(e);\n                }\n            }\n        }\n    }\n\n    @Override\n    public PulsarWorkerService worker() {\n        try {\n            return Objects.requireNonNull(workerServiceSupplier.get());\n        } catch (Throwable t) {\n            log.info().exception(t).log(\"Failed to get worker service\");\n            throw t;\n        }\n    }\n\n    boolean isWorkerServiceAvailable() {\n        WorkerService workerService = workerServiceSupplier.get();\n        if (workerService == null) {","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/ComponentImpl.java#L238-L274","documentation":"ComponentImpl.getComponentStatus() gathers status from the workers holding assignments; when it must fetch status remotely via PulsarAdmin and the admin call throws a PulsarAdminException, it wraps it in a plain RuntimeException (which becomes an HTTP 500). The real cause (connection failure, auth error, missing function, etc.) is inside the nested PulsarAdminException.","triggerScenarios":"Requesting component (function/sink/source) status where assignments are spread across multiple workers and one remote worker's getStatus call fails: target worker down, TLS/auth misconfiguration between workers, function not found on the remote worker, or timeout.","commonSituations":"A worker in the cluster crashed or was drained while its assignment still exists; inter-worker admin URLs misconfigured (wrong host/port/TLS); security settings changed on one worker but not others.","solutions":["Read the wrapped PulsarAdminException cause to identify the underlying problem.","Check that all workers listed in the assignments are up and reachable at their configured admin URLs.","Fix inter-worker connectivity/TLS/auth configuration and re-run status.","Remove stale assignments (e.g. via rebalance or restarting the scheduler) if a dead worker's assignments linger."],"exampleFix":"// before\ntry {\n    return getStatus(tenant, namespace, name, assignments, uri);\n} catch (PulsarAdminException e) {\n    throw new RuntimeException(e); // opaque 500\n}\n// after\ntry {\n    return getStatus(tenant, namespace, name, assignments, uri);\n} catch (PulsarAdminException e) {\n    log.error(\"Status fetch failed for {}\", name, e);\n    throw new RestException(Status.INTERNAL_SERVER_ERROR,\n        \"Failed to get status: \" + e.getHttpError() != null ? e.getHttpError() : e.getMessage());\n}","handlingStrategy":"try-catch","validationCode":"// verify all assignment-holding workers are reachable before fetching status\nfor (WorkerAssignmentInfo a : assignments) {\n    if (!isWorkerReachable(a.getWorkerId())) {\n        throw new IllegalStateException(\"Worker \" + a.getWorkerId() + \" unreachable\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    return getStatus(tenant, namespace, name, assignments, uri);\n} catch (RuntimeException e) {\n    Throwable cause = e.getCause();\n    if (cause instanceof PulsarAdminException) {\n        // inspect the PulsarAdminException for the real failure\n    }\n    throw e;\n}","preventionTips":["Monitor worker liveness; keep assignments consistent with live workers","Keep inter-worker admin URL/TLS/auth configuration uniform","Unwrap RuntimeException.getCause() to diagnose the PulsarAdminException"],"tags":["pulsar-functions","status","pulsar-admin","wrapped-exception"],"backgroundTag":"pulsar-admin-call-failed","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}