{"record":{"id":"ddbee2c4d523502f","repo":"aeron-io/aeron","slug":"einval-unknown-correlation-id","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/ExclusivePublication.h","lineNumber":774,"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 Publication::addDestination\n     * @see Publication::removeDestination\n     *\n     * @param correlationId of the add/remove command returned by Publication::addDestination\n     * or Publication::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":756,"sourceCodeEnd":792,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/cpp_wrapper/ExclusivePublication.h#L756-L792","documentation":"Thrown by ExclusivePublication::findDestinationResponse(correlationId) when the given correlation id is not present in the publication's m_pendingDestinations map. This means no async addDestination/removeDestination call registered with that id, or the response was already consumed. The library treats looking up an unknown correlation id as an invalid-argument error rather than returning false.","triggerScenarios":"Passing a correlationId that was never returned from addDestination/removeDestination, calling findDestinationResponse twice with the same id, or querying after the pending entry was resolved and erased.","commonSituations":"Application code that reuses or guesses correlation ids, polls for a destination response after a prior successful poll already consumed the entry, or loses track of the ids returned by async add/removeDestination.","solutions":["Store the correlationId returned by ExclusivePublication::addDestination/removeDestination and only query with that exact value.","Treat findDestinationResponse as single-shot: after the entry resolves, do not call it again with the same id.","Check control-flow so the id passed is from the current publication's pending set, not another publication's or a Subscription's.","Wrap the call in try-catch for IllegalArgumentException if correlation bookkeeping might be stale, and re-issue the add/removeDestination instead."],"exampleFix":"// before\nlong id = someGuessedId;\npublication.findDestinationResponse(id); // not in m_pendingDestinations\n// after\nlong id = publication.addDestination(\"aeron:udp?endpoint=localhost:40456\");\nif (publication.findDestinationResponse(id)) { /* done, do not reuse id */ }","handlingStrategy":"validation","validationCode":"std::unordered_set<long> pendingIds;\nlong id = publication.addDestination(uri);\npendingIds.insert(id);\n// before calling: if (!pendingIds.count(id)) skip or re-add;","typeGuard":null,"tryCatchPattern":"try {\n  if (publication.findDestinationResponse(id)) { pendingIds.erase(id); }\n} catch (const aeron::util::IllegalArgumentException&) {\n  log(\"stale correlation id; re-adding destination\");\n  id = publication.addDestination(uri);\n}","preventionTips":["Store the correlationId returned by addDestination/removeDestination","Consume each id exactly once; erase after resolution","Do not share ids between ExclusivePublication instances","Re-register destinations after restart instead of replaying old ids"],"tags":["aeron","cpp","publication","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"}