{"record":{"id":"ef5f8687a3a4ac9f","repo":"apache/pulsar","slug":"restexception-e-getcause","errorCode":null,"errorMessage":"RestException(e.getCause())","messagePattern":"RestException\\(e\\.getCause\\(\\)\\)","errorType":"exception","errorClass":"RestException","httpStatus":null,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/NonPersistentTopics.java","lineNumber":705,"sourceCode":"                            .attr(\"namespace\", namespace)\n                            .attr(\"topic\", topicName.getLocalName())\n                            .attr(\"isGlobal\", isGlobal)\n                            .log(\"Successfully remove entry filters\");\n                    asyncResponse.resume(Response.noContent().build());\n                })\n                .exceptionally(ex -> {\n                    handleTopicPolicyException(\"removeEntryFilters\", ex, asyncResponse);\n                    return null;\n                });\n    }\n\n    private Topic getTopicReference(TopicName topicName) {\n        try {\n            return pulsar().getBrokerService().getTopicIfExists(topicName.toString())\n                    .get(config().getMetadataStoreOperationTimeoutSeconds(), TimeUnit.SECONDS)\n                    .orElseThrow(() -> new RestException(Status.NOT_FOUND, \"Topic not found\"));\n        } catch (ExecutionException e) {\n            throw new RestException(e.getCause());\n        } catch (InterruptedException | TimeoutException e) {\n            throw new RestException(e);\n        }\n    }\n}\n","sourceCodeStart":687,"sourceCodeEnd":711,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/NonPersistentTopics.java#L687-L711","documentation":"getTopicReference waits for getTopicIfExists(...) future and, when the future completes exceptionally, wraps the underlying cause in a RestException. The message string shown is the generic wrapping, but the actual HTTP response reflects the cause (e.g. topic load failure, broker service error). It indicates the topic lookup failed on the broker while serving a non-persistent topic admin read (e.g. GET topic stats/permissions).","triggerScenarios":"Any admin call that resolves to getTopicReference when BrokerService.getTopicIfExists completes exceptionally — e.g. metadata store errors, topic load failures — within metadataStoreOperationTimeoutSeconds.","commonSituations":"Metadata store (ZooKeeper/etcd) connectivity problems, topic being concurrently deleted, broker service exceptions during topic creation/load.","solutions":["Inspect the cause field of the returned RestException / the broker log for the real underlying error","Verify metadata store connectivity and health of the broker serving the request","Retry the admin call once the broker/metadata store is healthy"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-check: confirm topic exists and broker is healthy\nadmin.topics().getList(namespace).contains(topicName);","typeGuard":null,"tryCatchPattern":"try { t = admin.topics().stats(topic); } catch (PulsarAdminException e) { log.error(\"topic lookup failed: {}\", e.getCause()); }","preventionTips":["Monitor metadata store health; most causes are store errors","Add broker-side timeout headroom via metadataStoreOperationTimeoutSeconds","Retry idempotent admin reads on transient failures"],"tags":["rest-api","broker","topic-lookup"],"backgroundTag":"topic-lookup-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"}