{"record":{"id":"8d58f2ed8e7a467b","repo":"elastic/elasticsearch","slug":"unexpected-token-token-currentfieldname-in-8d58f2","errorCode":null,"errorMessage":"Unexpected token {token} [{currentFieldName}] in [{aggregationName}].","messagePattern":"Unexpected token (.+?) \\[(.+?)\\] in \\[(.+?)\\]\\.","errorType":"validation","errorClass":"ParsingException","httpStatus":null,"severity":"error","filePath":"modules/aggregations/src/main/java/org/elasticsearch/aggregations/metric/ArrayValuesSourceParser.java","lineNumber":91,"sourceCode":"            } else if (token == XContentParser.Token.VALUE_STRING) {\n                if (CommonFields.FIELDS.match(currentFieldName, parser.getDeprecationHandler())) {\n                    fields = Collections.singletonList(parser.text());\n                } else if (formattable && CommonFields.FORMAT.match(currentFieldName, parser.getDeprecationHandler())) {\n                    format = parser.text();\n                } else if (CommonFields.VALUE_TYPE.match(currentFieldName, parser.getDeprecationHandler())) {\n                    throw new ParsingException(\n                        parser.getTokenLocation(),\n                        \"Unexpected token \"\n                            + token\n                            + \" [\"\n                            + currentFieldName\n                            + \"] in [\"\n                            + aggregationName\n                            + \"]. \"\n                            + \"Multi-field aggregations do not support scripts.\"\n                    );\n                } else if (token(aggregationName, currentFieldName, token, parser, otherOptions) == false) {\n                    throw new ParsingException(\n                        parser.getTokenLocation(),\n                        \"Unexpected token \" + token + \" [\" + currentFieldName + \"] in [\" + aggregationName + \"].\"\n                    );\n                }\n            } else if (token == XContentParser.Token.START_OBJECT) {\n                if (CommonFields.MISSING.match(currentFieldName, parser.getDeprecationHandler())) {\n                    missingMap = new HashMap<>();\n                    while (parser.nextToken() != XContentParser.Token.END_OBJECT) {\n                        parseMissingAndAdd(aggregationName, currentFieldName, parser, missingMap);\n                    }\n                } else if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {\n                    throw new ParsingException(\n                        parser.getTokenLocation(),\n                        \"Unexpected token \"\n                            + token\n                            + \" [\"\n                            + currentFieldName\n                            + \"] in [\"","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/aggregations/src/main/java/org/elasticsearch/aggregations/metric/ArrayValuesSourceParser.java#L73-L109","documentation":"Error \"Unexpected token {token} [{currentFieldName}] in [{aggregationName}].\" thrown in elastic/elasticsearch.","triggerScenarios":"Thrown at modules/aggregations/src/main/java/org/elasticsearch/aggregations/metric/ArrayValuesSourceParser.java:91 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}