{"record":{"id":"0c7de099cf5da29f","repo":"aeron-io/aeron","slug":"einval-0c7de0","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/Publication.h","lineNumber":755,"sourceCode":"     * - 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        std::lock_guard<std::recursive_mutex> lock(m_adminLock);\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":737,"sourceCodeEnd":773,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/cpp_wrapper/Publication.h#L737-L773","documentation":"Thrown by Publication::findDestinationResponse(correlationId) when the correlation id is not found among the publication's pending destinations (m_pendingDestinations), while holding the admin lock. Each async addDestination/removeDestination registers an id that is consumed exactly once; querying an unregistered or already-resolved id throws. The library signals this as EINVAL rather than a not-found return value.","triggerScenarios":"Calling findDestinationResponse with an id not obtained from this Publication's addDestination/removeDestination, polling twice with the same id, or passing a Subscription or ExclusivePublication id to a different object.","commonSituations":"Correlation-id bookkeeping bugs in application code, duplicate polling loops that never clear consumed ids, or IDs persisted and replayed after a restart where pending state is gone.","solutions":["Keep a one-to-one record of ids returned by addDestination/removeDestination and discard each id after its first successful findDestinationResponse.","Confirm the id belongs to this exact Publication instance (not a Subscription or ExclusivePublication).","After a restart, re-issue add/removeDestination rather than reusing persisted correlation ids.","Guard with try-catch on IllegalArgumentException and fall back to re-registering the destination."],"exampleFix":"// before\npublication.findDestinationResponse(id);\n// ... later\npublication.findDestinationResponse(id); // second poll of same id throws\n// after\nif (publication.findDestinationResponse(id)) { id = -1; /* mark consumed */ }","handlingStrategy":"validation","validationCode":"std::unordered_map<long, std::string> pending;\nlong id = publication.addDestination(uri);\npending[id] = uri;\n// before querying: if (!pending.count(id)) { /* re-add instead */ }","typeGuard":null,"tryCatchPattern":"try {\n  if (publication.findDestinationResponse(id)) { pending.erase(id); }\n} catch (const aeron::util::IllegalArgumentException&) {\n  log(\"unknown correlation id; re-registering destination\");\n}","preventionTips":["Track each addDestination/removeDestination id and retire it after first resolution","Never poll the same correlation id twice","Keep Publication/Subscription/ExclusivePublication id namespaces separate","After restart, re-issue destination commands rather than reusing persisted 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"}