{"record":{"id":"11bba96dd50b5024","repo":"apache/kafka","slug":"the-node-does-not-support-apikey","errorCode":null,"errorMessage":"The node does not support {apiKey}","messagePattern":"The node does not support (.+?)","errorType":"exception","errorClass":"UnsupportedVersionException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/clients/NodeApiVersions.java","lineNumber":151,"sourceCode":"        this.finalizedFeatures = new HashMap<>();\n        for (ApiVersionsResponseData.FinalizedFeatureKey finalizedFeature : nodeFinalizedFeatures) {\n            this.finalizedFeatures.put(finalizedFeature.name(), finalizedFeature.maxVersionLevel());\n        }\n    }\n\n    /**\n     * Return the most recent version supported by both the node and the local software.\n     */\n    public short latestUsableVersion(ApiKeys apiKey) {\n        return latestUsableVersion(apiKey, apiKey.oldestVersion(), apiKey.latestVersion());\n    }\n\n    /**\n     * Get the latest version supported by the broker within an allowed range of versions\n     */\n    public short latestUsableVersion(ApiKeys apiKey, short oldestAllowedVersion, short latestAllowedVersion) {\n        if (!supportedVersions.containsKey(apiKey))\n            throw new UnsupportedVersionException(\"The node does not support \" + apiKey);\n        ApiVersion supportedVersion = supportedVersions.get(apiKey);\n        Optional<ApiVersion> intersectVersion = ApiVersionsResponse.intersect(supportedVersion,\n            new ApiVersion()\n                .setApiKey(apiKey.id)\n                .setMinVersion(oldestAllowedVersion)\n                .setMaxVersion(latestAllowedVersion));\n\n        if (intersectVersion.isPresent())\n            return intersectVersion.get().maxVersion();\n        else\n            throw new UnsupportedVersionException(\"The node does not support \" + apiKey +\n                \" with version in range [\" + oldestAllowedVersion + \",\" + latestAllowedVersion + \"]. The supported\" +\n                \" range is [\" + supportedVersion.minVersion() + \",\" + supportedVersion.maxVersion() + \"].\");\n    }\n\n    /**\n     * Convert the object to a string with no linebreaks.<p/>\n     * <p>","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/apache/kafka/blob/996fb4585aa1bcc8980b0e1b8d6b168b986cd979/clients/src/main/java/org/apache/kafka/clients/NodeApiVersions.java#L133-L169","documentation":"Thrown by NodeApiVersions.latestUsableVersion() when the broker's reported API versions map does not contain an entry for the given ApiKeys. This means the broker entirely lacks support for that API key, so no version intersection is possible.","triggerScenarios":"Calling latestUsableVersion(apiKey, ...) where supportedVersions (from the broker's ApiVersionsResponse) has no entry for apiKey. The broker did not advertise this API at all.","commonSituations":"Client/broker version skew where the client uses a newer API key not yet known to an older broker (e.g. a KRaft-era API against a very old broker), or a broker that intentionally omits certain APIs.","solutions":["Upgrade the broker to a version that supports the required API key.","Downgrade the client to match the broker's supported API surface.","Check ApiVersionsResponse from the broker to confirm which API keys are advertised.","For optional features, gate the code path on broker version compatibility."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"NodeApiVersions versions = ...;\nif (!versions.supportedVersions.containsKey(apiKey)) {\n    throw new UnsupportedVersionException(\"Broker lacks API \" + apiKey);\n}","typeGuard":"boolean brokerSupportsApi(NodeApiVersions v, ApiKeys key) {\n    return v.supportedVersions().containsKey(key);\n}","tryCatchPattern":"try {\n    short v = nodeApiVersions.latestUsableVersion(apiKey);\n} catch (UnsupportedVersionException e) {\n    // broker does not support this API at all\n}","preventionTips":["Fetch and cache NodeApiVersions at connection time to gate features.","Document the minimum broker version for each feature you use.","Run compatibility checks in CI against the oldest supported broker."],"tags":["versioning","compatibility","api"],"backgroundTag":null,"analyzedSha":"996fb4585aa1bcc8980b0e1b8d6b168b986cd979","analyzedAt":"2026-08-11T22:03:28.655Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}