{"record":{"id":"b28cf1bf9d3a40c3","repo":"apache/pulsar","slug":"runtimeexception-err","errorCode":null,"errorMessage":"RuntimeException(err)","messagePattern":"RuntimeException\\(err\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Namespaces.java","lineNumber":3622,"sourceCode":"                            }\n                            String json = objectWriter().writeValueAsString(data);\n                            out.write(json);\n                        }\n\n                        @Override\n                        public void finished(int total, int errors, int unknown) throws Exception {\n                            out.append(\"]\\n\");\n                            out.append(\"\\\"total\\\": \" + total + \",\\n\");\n                            out.append(\"\\\"errors\\\": \" + errors + \",\\n\");\n                            out.append(\"\\\"unknown\\\": \" + unknown + \"\\n\");\n                        }\n                    });\n                    out.append(\"}\");\n                    out.flush();\n                    outputStream.flush();\n                } catch (Exception err) {\n                    log.error().exception(err).log(\"error\");\n                    throw new RuntimeException(err);\n                }\n            };\n            return Response.ok(output).type(MediaType.APPLICATION_JSON_TYPE).build();\n        } catch (Throwable err) {\n            log.error()\n                    .attr(\"namespace\", namespaceName)\n                    .exception(err)\n                    .log(\"Error while scanning offloaded ledgers for namespace\");\n            throw new RestException(Response.Status.INTERNAL_SERVER_ERROR,\n                    \"Error while scanning ledgers for \" + namespaceName);\n        }\n    }\n\n    @GET\n    @Path(\"/{tenant}/{namespace}/entryFilters\")\n    @Operation(summary = \"Get maxConsumersPerSubscription config on a namespace.\")\n    @ApiResponses(value = {\n            @ApiResponse(responseCode = \"200\", description = \"Get maxConsumersPerSubscription config on a namespace.\",","sourceCodeStart":3604,"sourceCodeEnd":3640,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Namespaces.java#L3604-L3640","documentation":"The namespaces getTiDBLedgers (offloaded-ledger scan) endpoint writes a JSON response through a StreamingOutput; any exception raised inside that streaming lambda is logged and rethrown as a raw RuntimeException(err). Because streaming has already begun, the broker cannot convert it into a clean HTTP status, so the client typically sees a 500 or a truncated response body.","triggerScenarios":"GET /admin/v2/namespaces/{tenant}/{namespace}/tiDBLedgers (scan of offloaded ledgers) where an exception occurs while iterating ledgers or writing JSON to the output stream — e.g. metadata-service read failure or connection drop mid-stream.","commonSituations":"Underlying storage/meta store connectivity problems during the scan; very large namespace scans hitting timeouts; client disconnects causing stream write IOException; permission or topic-level errors surfacing after the response streaming started.","solutions":["Check the broker log for the accompanying 'error' entry to find the root cause exception wrapped in the RuntimeException.","Verify connectivity to the metadata service and offload storage (e.g. ledger offload driver credentials/bucket) and retry the scan.","Retry the request; if it recurs for large namespaces, narrow the scan scope or increase relevant timeouts."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!admin.namespaces().getNamespaces(tenant).contains(tenant + \"/\" + namespace)) {\n    throw new IllegalStateException(\"namespace does not exist\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return admin.namespaces().getTiDBLedgers(tenant, namespace);\n} catch (PulsarAdminException e) {\n    if (e instanceof PulsarAdminException.HttpErrorException\n            && ((PulsarAdminException.HttpErrorException) e).getStatusCode() == 500) {\n        // streaming failed mid-way; inspect broker logs and retry with backoff\n        return retryWithBackoff(() -> admin.namespaces().getTiDBLedgers(tenant, namespace));\n    }\n    throw e;\n}","preventionTips":["Ensure metadata-service and offload-storage connectivity before running scans.","Handle truncated response bodies on 500s — data streamed before failure is incomplete.","Keep scans scoped and schedule them off-peak to avoid stream timeouts."],"tags":["pulsar","admin-api","runtime-exception","streaming-response","offloading"],"backgroundTag":"stream-write-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"}