appwrite/appwrite · error · Appwrite\Extend\Exception

subscriber_not_found

subscriber_not_found

Error message

Subscriber with the request ID could not be found.

What it means

Thrown when the subscriber document does not exist or its topicId attribute does not match the path's topicId. Matching the subscriber to the topic prevents cross-topic subscriber ID leakage. Note it fires only after the topic itself was found.

Solutions

  1. Fetch the subscriber through the topic it belongs to: GET /messaging/topics/{correctTopicId}/subscribers/{subscriberId}.
  2. List the topic's subscribers (GET /messaging/topics/{topicId}/subscribers) to confirm the ID.
  3. Handle 404 gracefully in the client — subscribers can be deleted at any time by users or token expiry flows.

Example fix

// before
$s = $messaging->getSubscriber($topicAId, $subscriberId); // subscriber is in topic B
// after
$s = $messaging->getSubscriber($topicBId, $subscriberId);
Defensive patterns

Strategy: try-catch

Validate before calling

$sub = $messaging->getSubscriber($topicId, $subscriberId); // 404 if not in this topic

Try / catch

try {
    $s = $messaging->getSubscriber($topicId, $subscriberId);
} catch (AppwriteException $e) {
    if ($e->getCode() === 404) { /* subscriber absent or in another topic */ }
    else throw $e;
}

Prevention

When it happens

Trigger: GET /messaging/topics/{topicId}/subscribers/{subscriberId} where the subscriber was deleted, the ID is wrong, or the subscriber belongs to a different topic.

Common situations: Using a subscriber ID stored from another topic; listing via a stale cursor then fetching a since-deleted subscriber; typo in subscriberId.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of appwrite/appwrite@ca3c55abfe (2026-09-16). Data as JSON: /api/errors/dd774e66063bca0c. Report an issue: GitHub.

Appendix: source

Thrown at src/Appwrite/Platform/Modules/Messaging/Http/Topics/Subscribers/Get.php:66

            ->param('subscriberId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Subscriber ID.', false, ['dbForProject'])
            ->inject('dbForProject')
            ->inject('authorization')
            ->inject('response')
            ->callback($this->action(...));
    }

    public function action(string $topicId, string $subscriberId, Database $dbForProject, Authorization $authorization, Response $response)
    {
        $topic = $authorization->skip(fn () => $dbForProject->getDocument('topics', $topicId));

        if ($topic->isEmpty()) {
            throw new Exception(Exception::TOPIC_NOT_FOUND);
        }

        $subscriber = $dbForProject->getDocument('subscribers', $subscriberId);

        if ($subscriber->isEmpty() || $subscriber->getAttribute('topicId') !== $topicId) {
            throw new Exception(Exception::SUBSCRIBER_NOT_FOUND);
        }

        $target = $authorization->skip(fn () => $dbForProject->getDocument('targets', $subscriber->getAttribute('targetId')));
        $user = $authorization->skip(fn () => $dbForProject->getDocument('users', $target->getAttribute('userId')));

        $subscriber
            ->setAttribute('target', $target)
            ->setAttribute('userName', $user->getAttribute('name'));

        $response
            ->dynamic($subscriber, Response::MODEL_SUBSCRIBER);
    }
}

View on GitHub (pinned to ca3c55abfe)