{"record":{"id":"9f10ada1e30aca75","repo":"aeron-io/aeron","slug":"einval-9f10ad","errorCode":"EINVAL","errorMessage":"Unknown correlation id","messagePattern":"Unknown correlation id","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/cpp_wrapper/Subscription.h","lineNumber":383,"sourceCode":"     *\n     * - If the correlationId is unknown, then an exception is thrown.\n     * - If the media driver has not answered the add/remove command, then a false is returned.\n     * - If the media driver has successfully added or removed the destination then true is returned.\n     * - If the media driver has returned an error, this method will throw the error returned.\n     *\n     * @see Subscription::addDestination\n     * @see Subscription::removeDestination\n     *\n     * @param correlationId of the add/remove command returned by Subscription::addDestination\n     * or Subscription::removeDestination\n     * @return true for added or false if not.\n     */\n    bool findDestinationResponse(std::int64_t correlationId)\n    {\n        auto search = m_pendingDestinations.find(correlationId);\n        if (search == m_pendingDestinations.end())\n        {\n            throw IllegalArgumentException(\"Unknown correlation id\", SOURCEINFO, EINVAL);\n        }\n\n        auto async = search->second;\n        try\n        {\n            bool result = findDestinationResponse(async);\n            if (result)\n            {\n                m_pendingDestinations.erase(correlationId);\n            }\n            return result;\n        }\n        catch (...)\n        {\n            m_pendingDestinations.erase(correlationId);\n            throw;\n        }\n    }","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/cpp_wrapper/Subscription.h#L365-L401","documentation":"Thrown by Subscription::findDestinationResponse(correlationId) when the correlation id is absent from the subscription's m_pendingDestinations map. Only ids returned by this Subscription's async addDestination/removeDestination calls are valid, and each is resolved exactly once. Querying an unknown id raises IllegalArgumentException with EINVAL instead of a soft failure.","triggerScenarios":"Polling findDestinationResponse with an id never registered by this Subscription's addDestination/removeDestination, a duplicate poll of an already-consumed id, or cross-object id reuse.","commonSituations":"Applications that lose the id returned by async addDestination, retry logic that re-polls consumed ids, or confusion between Subscription and Publication correlation-id namespaces.","solutions":["Capture and store the id returned by Subscription::addDestination/removeDestination and use only that value.","Consume each id once: stop polling after findDestinationResponse resolves it.","Do not mix correlation ids between different Subscription or Publication instances.","If the id may be stale, catch IllegalArgumentException and re-issue the addDestination/removeDestination call."],"exampleFix":"// before\nsubscription.findDestinationResponse(otherSubscriptionId); // wrong namespace\n// after\nlong id = subscription.addDestination(\"aeron:udp?endpoint=localhost:40456\");\nif (subscription.findDestinationResponse(id)) { /* consume once */ }","handlingStrategy":"validation","validationCode":"std::unordered_set<long> pendingSubIds;\nlong id = subscription.addDestination(uri);\npendingSubIds.insert(id);\n// guard: if (!pendingSubIds.count(id)) return false; // skip lookup, re-add if needed","typeGuard":null,"tryCatchPattern":"try {\n  if (subscription.findDestinationResponse(id)) { pendingSubIds.erase(id); }\n} catch (const aeron::util::IllegalArgumentException&) {\n  log(\"stale subscription correlation id\");\n  id = subscription.addDestination(uri);\n}","preventionTips":["Only query ids returned by this Subscription's own addDestination/removeDestination","Treat findDestinationResponse as one-shot per id","Never reuse Publication ids for Subscription lookups","Wrap lookups in try-catch in retry loops that may re-poll consumed ids"],"tags":["aeron","cpp","subscription","correlation-id","einval"],"backgroundTag":"record-not-found","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}