{"record":{"id":"e1008aef2ba4e523","repo":"elastic/elasticsearch","slug":"cannot-read-binary-value","errorCode":null,"errorMessage":"cannot read binary value","messagePattern":"cannot read binary value","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/JsonProcessor.java","lineNumber":114,"sourceCode":"            )\n        ) {\n            parser.allowDuplicateKeys(allowDuplicateKeys);\n            XContentParser.Token token = parser.nextToken();\n            Object value = null;\n            if (token == XContentParser.Token.VALUE_NULL) {\n                value = null;\n            } else if (token == XContentParser.Token.VALUE_STRING) {\n                value = parser.text();\n            } else if (token == XContentParser.Token.VALUE_NUMBER) {\n                value = parser.numberValue();\n            } else if (token == XContentParser.Token.VALUE_BOOLEAN) {\n                value = parser.booleanValue();\n            } else if (token == XContentParser.Token.START_OBJECT) {\n                value = parser.map();\n            } else if (token == XContentParser.Token.START_ARRAY) {\n                value = parser.list();\n            } else if (token == XContentParser.Token.VALUE_EMBEDDED_OBJECT) {\n                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);","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/JsonProcessor.java#L96-L132","documentation":"Thrown by JsonProcessor.apply when the XContent parser emits a VALUE_EMBEDDED_OBJECT token, which means the input field contained a base64-decoded binary blob. JSON ingest does not support binary values at the top level, so the processor refuses. IllegalArgumentException guarding against binary content sneaking through.","triggerScenarios":"The field passed to json ingest contains an embedded/binary object token (e.g. CBOR/SMILE binary content fed into the JSON parser, or a base64 value decoded by the parser).","commonSituations":"Mixed serialization formats (SMILE/CBOR fed to a JSON parser), corrupted input, or upstream producer emitting binary values where a string was expected.","solutions":["Ensure the source field contains a genuine JSON-encoded string, not binary.","If binary content is expected, decode it before the json processor or use a different parser.","Sanitize upstream producers that emit non-JSON content into the field."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure the source field is a plain string, not a binary-embedded value\nObject v = ctx.get(fieldName);\nif (v instanceof byte[]) {\n    throw new IllegalArgumentException(\"binary value not allowed for json processor\");\n}","typeGuard":"static boolean isJsonSafe(Object v) {\n    return v == null || v instanceof String || v instanceof Number || v instanceof Boolean;\n}","tryCatchPattern":"try {\n    JsonProcessor.apply(value, allowDup, strict);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"cannot read binary value\")) {\n        // route binary content elsewhere\n    } else throw e;\n}","preventionTips":["Ensure upstream producers send JSON-encoded strings, not raw binary.","Verify serialization format matches parser (JSON parser needs JSON content).","Add a script processor to drop non-string values before the json processor."],"tags":["ingest","json","binary","type-mismatch"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}