{"record":{"id":"55c29e09baba049e","repo":"elastic/elasticsearch","slug":"the-input-is-not-valid-json-and-the-paramete","errorCode":null,"errorMessage":"The input {} is not valid JSON and the {} parameter is true","messagePattern":"The input (.+?) is not valid JSON and the (.+?) parameter is true","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/JsonProcessor.java","lineNumber":132,"sourceCode":"                throw new IllegalArgumentException(\"cannot read binary value\");\n            }\n            if (strictJsonParsing) {\n                String errorMessage = Strings.format(\n                    \"The input %s is not valid JSON and the %s parameter is true\",\n                    fieldValue,\n                    STRICT_JSON_PARSING_PARAMETER\n                );\n                /*\n                 * If strict JSON parsing is disabled, then once we've found the first token then we move on. For example for the string\n                 * \"123 \\\"foo\\\"\" we would just return the first token, 123. However, if strict parsing is enabled (which it is by default),\n                 * then we check to see whether there are any more tokens at this point. We expect the next token to be null. If there is\n                 * another token or if the parser blows up, then we know we had invalid JSON and we alert the user with an\n                 * IllegalArgumentException.\n                 */\n                try {\n                    token = parser.nextToken();\n                } catch (IllegalArgumentException e) {\n                    throw new IllegalArgumentException(errorMessage, e);\n                }\n                if (token != null) {\n                    throw new IllegalArgumentException(errorMessage);\n                }\n            }\n            return value;\n        } catch (IOException e) {\n            throw new IllegalArgumentException(e);\n        }\n    }\n\n    public static void apply(\n        Map<String, Object> ctx,\n        String fieldName,\n        boolean allowDuplicateKeys,\n        ConflictStrategy conflictStrategy,\n        boolean strictJsonParsing\n    ) {","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/JsonProcessor.java#L114-L150","documentation":"Thrown by JsonProcessor.apply (inside the strictJsonParsing branch) when parser.nextToken() throws an IllegalArgumentException after the first token has already been read. This means the first token parsed OK but a subsequent token violated JSON grammar — strict mode wraps the cause and reports the original fieldValue. IllegalArgumentException with cause.","triggerScenarios":"strict_json_parsing=true (default) and the input string starts with a valid JSON token but contains trailing garbage. E.g. \"123 abc\" parses '123' then fails on 'abc'.","commonSituations":"Concatenated JSON values in one field, partial JSON due to truncation, log-line prefixes/suffixes around the JSON payload, or producer bugs emitting multiple values.","solutions":["Fix the producer to emit a single valid JSON value in the field.","If trailing content is expected, set \"strict_json_parsing\": false (note: only the first token will then be used).","Pre-trim the field to a clean JSON value before the json processor."],"exampleFix":"// before\n{\"json\": {\"field\": \"raw\", \"target_field\": \"parsed\"}}\n// data: raw = '123 \"extra\"'\n// after\n{\"json\": {\"field\": \"raw\", \"target_field\": \"parsed\", \"strict_json_parsing\": false}}","handlingStrategy":"validation","validationCode":"// Pre-check: parse and verify exactly one token with strict rules\ntry (XContentParser p = JsonXContent.jsonXContent.createParser(\n        XContentParserConfiguration.EMPTY, value)) {\n    p.nextToken();\n    if (p.nextToken() != null) throw new IllegalArgumentException(\"not a single JSON value\");\n} catch (IOException ioe) { /* invalid */ }","typeGuard":null,"tryCatchPattern":"try {\n    JsonProcessor.apply(value, allowDup, true);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"not valid JSON\")) {\n        // retry with strict_json_parsing=false or route to failure store\n    } else throw e;\n}","preventionTips":["If your data legitimately has trailing tokens, set strict_json_parsing=false.","Validate producer output emits a single JSON value per field.","Add unit tests for representative field values before deploying the pipeline."],"tags":["ingest","json","strict-parsing","data"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}