{"record":{"id":"7a163ee64bd12f61","repo":"elastic/elasticsearch","slug":"deprecated-fields-not-supported-here-but-got-old","errorCode":null,"errorMessage":"deprecated fields not supported here but got [{oldName}] which is a deprecated name for [{replacedName}]","messagePattern":"deprecated fields not supported here but got \\[(.+?)\\] which is a deprecated name for \\[(.+?)\\]","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"libs/x-content/src/main/java/org/elasticsearch/xcontent/DeprecationHandler.java","lineNumber":41,"sourceCode":"     * to fail fast when parsing deprecated fields.\n     */\n    DeprecationHandler THROW_UNSUPPORTED_OPERATION = new DeprecationHandler() {\n        @Override\n        public void logReplacedField(String parserName, Supplier<XContentLocation> location, String oldName, String replacedName) {\n            if (parserName != null) {\n                throw new UnsupportedOperationException(\n                    \"deprecated fields not supported in [\"\n                        + parserName\n                        + \"] but got [\"\n                        + oldName\n                        + \"] at [\"\n                        + location.get()\n                        + \"] which is a deprecated name for [\"\n                        + replacedName\n                        + \"]\"\n                );\n            } else {\n                throw new UnsupportedOperationException(\n                    \"deprecated fields not supported here but got [\" + oldName + \"] which is a deprecated name for [\" + replacedName + \"]\"\n                );\n            }\n        }\n\n        @Override\n        public void logRenamedField(String parserName, Supplier<XContentLocation> location, String oldName, String currentName) {\n            if (parserName != null) {\n                throw new UnsupportedOperationException(\n                    \"deprecated fields not supported in [\"\n                        + parserName\n                        + \"] but got [\"\n                        + oldName\n                        + \"] at [\"\n                        + location.get()\n                        + \"] which has been replaced with [\"\n                        + currentName\n                        + \"]\"","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/x-content/src/main/java/org/elasticsearch/xcontent/DeprecationHandler.java#L23-L59","documentation":"Same THROW_UNSUPPORTED_OPERATION.logReplacedField path as 867, but parserName is null so the message omits the parser context. This variant surfaces when the parser was created without a parserName but still configured to throw on deprecated fields. The deprecated alias maps to a replacement field name.","triggerScenarios":"Parsing with THROW_UNSUPPORTED_OPERATION on a parser whose parserName is null (e.g. ad-hoc parser created without a name), and the input contains a deprecated 'replaced' field alias.","commonSituations":"Unit tests or one-off parsers created without naming the parser. Shared utility parsers reused across contexts without a parserName.","solutions":["Switch the deprecated alias to its replacement name shown in the message.","Pass a parserName when creating the parser so future errors carry more context, and/or switch to a lenient deprecation handler if legacy names are acceptable.","Register the alias as non-deprecated if it is now a first-class supported name."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// provide a parserName so this variant doesn't occur, and rename deprecated aliases\n// e.g. ensure body uses the replacement field before parsing","typeGuard":null,"tryCatchPattern":"try {\n    p.parse(parser, ctx);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().startsWith(\"deprecated fields not supported here\") && e.getMessage().contains(\"deprecated name for [\")) {\n        // rename to replacement and retry\n    }\n}","preventionTips":["Always pass a parserName when creating parsers for clearer errors (avoids the null-parserName variant).","Normalize deprecated 'replaced' aliases upstream of strict parsing.","Reserve THROW_UNSUPPORTED_OPERATION for contexts that can tolerate hard failure."],"tags":["xcontent","deprecation","strict","field-alias"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}