{"record":{"id":"993d9f6d0e48f4a4","repo":"apache/pulsar","slug":"subscription-not-found","errorCode":null,"errorMessage":"Subscription not found","messagePattern":"Subscription not found","errorType":"http","errorClass":"RestException","httpStatus":404,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java","lineNumber":1718,"sourceCode":"                    if (partitionMetadata.partitions > 0) {\n                        final List<CompletableFuture<Void>> futures = new ArrayList<>();\n                        PulsarAdmin adminClient;\n                        try {\n                            adminClient = pulsar().getAdminClient();\n                        } catch (PulsarServerException e) {\n                            return CompletableFuture.failedFuture(e);\n                        }\n                        for (int i = 0; i < partitionMetadata.partitions; i++) {\n                            TopicName topicNamePartition = topicName.getPartition(i);\n                            futures.add(adminClient.topics()\n                                    .deleteSubscriptionAsync(topicNamePartition.toString(), subName, force));\n                        }\n\n                        return FutureUtil.waitForAll(futures).handle((result, exception) -> {\n                            if (exception != null) {\n                                Throwable t = exception.getCause();\n                                if (t instanceof NotFoundException) {\n                                    throw new RestException(Status.NOT_FOUND,\n                                            \"Subscription not found\");\n                                } else if (t instanceof PreconditionFailedException) {\n                                    throw new RestException(Status.PRECONDITION_FAILED,\n                                            \"Subscription has active connected consumers\");\n                                } else {\n                                    throw new RestException(t);\n                                }\n                            }\n                            return null;\n                        });\n                    }\n                    return internalDeleteSubscriptionForNonPartitionedTopicAsync(subName, authoritative, force);\n                });\n            }\n        });\n    }\n\n    // Note: this method expects the caller to check authorization","sourceCodeStart":1700,"sourceCodeEnd":1736,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java#L1700-L1736","documentation":"HTTP 404 returned when deleting a subscription across all partitions of a partitioned topic. Each partition's delete is attempted and the results aggregated; if any partition throws NotFoundException (the subscription cursor does not exist there), the broker surfaces 'Subscription not found'. This means the named subscription does not (fully) exist on the topic's partitions.","triggerScenarios":"DELETE /admin/v2/persistent/{ns}/{topic}/subscription/{subName} (or `pulsar-admin topics unsubscribe`) where the subscription was already deleted, never created, or exists on some partitions but not all of a partitioned topic.","commonSituations":"Double unsubscribe from client code or automation; subscription auto-deleted after its last consumer disconnected (allowAutoSubscriptionDeletion / inactive deletion policies); partially-created subscription during a failed previous operation; typo in subscription name.","solutions":["Check existing subscriptions with `pulsar-admin topics subscriptions <topic>` and correct the subscription name.","Treat 404 as success in idempotent unsubscribe flows (catch and continue).","If the subscription exists on some partitions only, delete it per-partition (topic-partition-N) or recreate it and delete again to converge.","Review auto-delete policies (namespace/topic subscription expiration) that may remove idle subscriptions."],"exampleFix":"// before\nadmin.topics().deleteSubscription(\"persistent://t/ns/topic\", \"my-sub\"); // 404 if already gone\n// after\ntry {\n    admin.topics().deleteSubscription(\"persistent://t/ns/topic\", \"my-sub\");\n} catch (PulsarAdminException.NotFoundException e) {\n    // already unsubscribed; ignore\n}","handlingStrategy":"try-catch","validationCode":"if (!admin.topics().getSubscriptions(topic).contains(subName)) {\n    return; // nothing to unsubscribe\n}\nadmin.topics().deleteSubscription(topic, subName);","typeGuard":null,"tryCatchPattern":"try {\n    admin.topics().deleteSubscription(topic, subName);\n} catch (PulsarAdminException.NotFoundException e) {\n    // subscription already gone; idempotent success\n}","preventionTips":["Make unsubscribe flows idempotent","Check subscriptions list before deletion","Review subscription auto-expiration policies that remove idle subs"],"tags":["pulsar","subscription","rest-api"],"backgroundTag":"subscription-not-found","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"}