{"record":{"id":"0450ab66d39d50ba","repo":"elastic/elasticsearch","slug":"unable-to-parse-with-name-parser-didn-t-m","errorCode":null,"errorMessage":"unable to parse {} with name [{}]: parser didn't match","messagePattern":"unable to parse (.+?) with name \\[(.+?)\\]: parser didn't match","errorType":"exception","errorClass":"XContentParseException","httpStatus":null,"severity":"error","filePath":"libs/x-content/src/main/java/org/elasticsearch/xcontent/NamedXContentRegistry.java","lineNumber":182,"sourceCode":"\n    // scope for testing\n    public <T> Entry lookupParser(Class<T> categoryClass, String name, XContentParser parser) {\n        Map<String, Entry> parsers = registry.getOrDefault(parser.getRestApiVersion(), emptyMap()).get(categoryClass);\n        if (parsers == null) {\n            if (registry.isEmpty()) {\n                // The \"empty\" registry will never work so we throw a better exception as a hint.\n                throw new XContentParseException(\"named objects are not supported for this parser\");\n            }\n            throw new XContentParseException(\"unknown named object category [\" + categoryClass.getName() + \"]\");\n        }\n        Entry entry = parsers.get(name);\n        if (entry == null) {\n            throw new NamedObjectNotFoundException(parser.getTokenLocation(), \"unknown field [\" + name + \"]\", parsers.keySet());\n        }\n        if (false == entry.name.match(name, parser.getDeprecationHandler())) {\n            /* Note that this shouldn't happen because we already looked up the entry using the names but we need to call `match` anyway\n             * because it is responsible for logging deprecation warnings. */\n            throw new XContentParseException(\n                parser.getTokenLocation(),\n                \"unable to parse \" + categoryClass.getSimpleName() + \" with name [\" + name + \"]: parser didn't match\"\n            );\n        }\n        return entry;\n    }\n\n}\n","sourceCodeStart":164,"sourceCodeEnd":191,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/x-content/src/main/java/org/elasticsearch/xcontent/NamedXContentRegistry.java#L164-L191","documentation":"After a name lookup succeeds (entry found), lookupParser calls entry.name.match() to run deprecation logging. If match returns false — which the comment says shouldn't happen because the entry was already located by name — it throws this defensive XContentParseException. Encountering it implies an inconsistency between the lookup map keys and the ParseField.match logic (e.g. a custom ParseField whose match disagrees with its registered name).","triggerScenarios":"A ParseField registered with a name but whose match() implementation rejects that exact name (custom ParseField subclass, or a registration bug). RestApiVersion-specific name resolution where match uses version-dependent logic that diverges from the map key used for lookup.","commonSituations":"Custom ParseField implementations with non-standard match semantics. Registry corruption during construction (duplicate/overlapping entries). Extremely rare in normal Elasticsearch usage.","solutions":["Audit any custom ParseField subclasses involved: match() must return true for the name used as the registry key.","Verify entries are registered under consistent names across RestApiVersions; a mismatch between the lookup map and match() causes this.","If using stock ParseField, this is likely a registry construction bug — check for duplicate registrations clobbering the entry."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// for custom ParseField, assert match is consistent with the registered name\nParseField pf = ...;\nassert pf.match(name, DeprecationHandler.IGNORE_DEPRECATIONS) : \"ParseField.match must accept its registered name\";","typeGuard":null,"tryCatchPattern":"try {\n    Entry e = registry.lookupParser(categoryClass, name, parser);\n} catch (XContentParseException ex) {\n    if (ex.getMessage().contains(\"parser didn't match\")) {\n        // audit custom ParseField.match and registry key consistency\n    }\n}","preventionTips":["Avoid custom ParseField subclasses whose match() can reject their own registered name.","Register each named entry under identical names across all RestApiVersions.","Add a startup self-test that round-trips every registry entry through match()."],"tags":["xcontent","named-content","registry","parsefield","defensive"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}