{"record":{"id":"61644fc71f447f94","repo":"elastic/elasticsearch","slug":"parsefield-doesn-t-accept","errorCode":null,"errorMessage":"[{}] parsefield doesn't accept: {}","messagePattern":"\\[(.+?)\\] parsefield doesn't accept: (.+?)","errorType":"exception","errorClass":"XContentParseException","httpStatus":null,"severity":"error","filePath":"libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java","lineNumber":700,"sourceCode":"        private final ParseField parseField;\n        private final ValueType type;\n\n        FieldParser(Parser<Value, Context> parser, EnumSet<XContentParser.Token> supportedTokens, ParseField parseField, ValueType type) {\n            this.parser = parser;\n            this.supportedTokens = supportedTokens;\n            this.parseField = parseField;\n            this.type = type;\n        }\n\n        void assertSupports(String parserName, XContentParser xContentParser, XContentParser.Token currentToken, String currentFieldName) {\n            boolean match = parseField.match(\n                parserName,\n                xContentParser::getTokenLocation,\n                currentFieldName,\n                xContentParser.getDeprecationHandler()\n            );\n            if (match == false) {\n                throw new XContentParseException(\n                    xContentParser.getTokenLocation(),\n                    \"[\" + parserName + \"] parsefield doesn't accept: \" + currentFieldName\n                );\n            }\n            if (supportedTokens.contains(xContentParser.currentToken()) == false) {\n                throw new XContentParseException(\n                    xContentParser.getTokenLocation(),\n                    \"[\" + parserName + \"] \" + currentFieldName + \" doesn't support values of type: \" + currentToken\n                );\n            }\n        }\n\n        @Override\n        public String toString() {\n            String[] deprecatedNames = parseField.getDeprecatedNames();\n            String allReplacedWith = parseField.getAllReplacedWith();\n            String deprecated = \"\";\n            if (deprecatedNames != null && deprecatedNames.length > 0) {","sourceCodeStart":682,"sourceCodeEnd":718,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/x-content/src/main/java/org/elasticsearch/xcontent/ObjectParser.java#L682-L718","documentation":"Thrown inside FieldParser.assertSupports when ParseField.match() returns false for the current field name. ParseField.match() checks the name against the field's accepted names (primary, deprecated, and all-replaced-with) using the deprecation handler and REST API version. A false return means the field name is not valid under the current parsing context.","triggerScenarios":"The field name in the input does not match any of the ParseField's accepted names for the current REST API version. This can happen when a deprecated field name was fully removed in a newer API version, or when a field name was only valid in a specific version range and the parser is operating under a different version.","commonSituations":"Using a deprecated field name that has been removed in the target REST API version. Sending a request with Accept/Content-Type headers specifying a REST API version where the field name is no longer accepted. Client and server version mismatch where the client uses old field names.","solutions":["Check the error message for the rejected field name and replace it with the current accepted name.","Review the deprecation notes for the endpoint to find the replacement field name.","Ensure the REST API version header matches a version under which the field name is still valid.","Update the client library to a version that emits current field names."],"exampleFix":"// before — deprecated field name removed in current API version\n{\n  \"type\": \"string\"\n}\n\n// after — current accepted name\n{\n  \"type\": \"keyword\"\n}","handlingStrategy":"validation","validationCode":"// Before sending, check field names against current API version's accepted names\nSet<String> currentFieldNames = Set.of(\"query\", \"size\", \"from\", \"sort\", \"aggs\");\nfor (String key : body.keySet()) {\n    if (!currentFieldNames.contains(key)) {\n        throw new IllegalArgumentException(\"Field '\" + key + \"' is not accepted in this API version\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    objectParser.parse(parser, context);\n} catch (XContentParseException e) {\n    if (e.getMessage().contains(\"parsefield doesn't accept\")) {\n        return badRequest(e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Keep client libraries updated to match the server's REST API version.","Review deprecation logs and migrate deprecated field names before they are removed.","Set the correct REST API version header to match the client's expected field names."],"tags":["parsing","xcontent","parsefield","deprecation","object-parser"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}