{"record":{"id":"d53c100a40613513","repo":"hibernate/hibernate-orm","slug":"unexpected-quote-read-in-current-processing-state","errorCode":null,"errorMessage":"unexpected quote read in current processing state {}","messagePattern":"unexpected quote read in current processing state (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/type/format/StringJsonDocumentReader.java","lineNumber":192,"sourceCode":"\t\t\t\t\t//   - if we are in the middle of an object :\n\t\t\t\t\t//        - if we just hit ':' that's a quoted value\n\t\t\t\t\t//        - if we just hit ',' that's a quoted key\n\t\t\t\t\tswitch ( this.processingStates.getCurrent() ) {\n\t\t\t\t\t\tcase STARTING_ARRAY:\n\t\t\t\t\t\t\t//this.processingStates.push( JsonProcessingState.ARRAY );\n\t\t\t\t\t\t\treturn JsonDocumentItemType.VALUE;\n\t\t\t\t\t\tcase ARRAY:\n\t\t\t\t\t\t\treturn JsonDocumentItemType.VALUE;\n\t\t\t\t\t\tcase STARTING_OBJECT:\n\t\t\t\t\t\t\t//this.processingStates.push( JsonProcessingState.OBJECT );\n\t\t\t\t\t\t\t//this.processingStates.push( JsonProcessingState.OBJECT_KEY_NAME );\n\t\t\t\t\t\t\treturn JsonDocumentItemType.VALUE_KEY;\n\t\t\t\t\t\tcase OBJECT: // we are processing object attribute value elements\n\t\t\t\t\t\t\treturn JsonDocumentItemType.VALUE;\n\t\t\t\t\t\tcase OBJECT_KEY_NAME: // we are processing object elements key\n\t\t\t\t\t\t\treturn JsonDocumentItemType.VALUE_KEY;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow new IllegalStateException( \"unexpected quote read in current processing state \" +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthis.processingStates.getCurrent() );\n\t\t\t\t\t}\n\t\t\t\tcase KEY_VALUE_SEPARATOR:  // that's the start of an attribute value\n\t\t\t\t\t//assert this.processingStates.getCurrent() == JsonProcessingState.OBJECT_KEY_NAME;\n\t\t\t\t\t// flush the OBJECT_KEY_NAME\n\t\t\t\t\t//this.processingStates.pop();\n\t\t\t\t\tbreak;\n\t\t\t\tcase SEPARATOR:\n\t\t\t\t\t// unless we are processing an array, following SEPARATOR that will a key\n\t\t\t\t\tbreak;\n\t\t\t\tcase OTHER:\n\t\t\t\t\t// here we are in front of a boolean, a null or a numeric value.\n\t\t\t\t\t// if none of these cases we're going to raise IllegalStateException\n\t\t\t\t\t// put back what we've read\n\t\t\t\t\tmoveBufferPosition(-1);\n\t\t\t\t\tfinal int valueSize = consumeNonStringValue();\n\t\t\t\t\tif (valueSize == -1) {\n\t\t\t\t\t\tthrow new IllegalStateException( \"Unrecognized marker: \" + StringJsonDocumentMarker.markerOf(","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/type/format/StringJsonDocumentReader.java#L174-L210","documentation":"While pulling items, the reader consumed a '\"' character, but the internal state machine is in a state where a quoted token is illegal — only STARTING_ARRAY, ARRAY, STARTING_OBJECT, OBJECT and OBJECT_KEY_NAME accept one (e.g. state NONE before any '{' or '[' was seen). The message appends the offending state, e.g. 'unexpected quote read in current processing state NONE'. Hibernate is rejecting structurally invalid JSON.","triggerScenarios":"next() reading a QUOTE marker while the state is NONE, ENDING_OBJECT or ENDING_ARRAY: a top-level string document like \"abc\" with no wrapping {} or []; trailing text after the root closes like {} \"x\"; a stray quote where the grammar requires ':', ',', '}' or ']'.","commonSituations":"JSON columns populated by hand or by another service that stores a bare serialized string instead of an object/array-rooted document; concatenating two JSON documents into one column value; storing the double-encoded JSON-string representation of an object.","solutions":["Inspect the exact column value that fails and make the document object- or array-rooted, with quotes only around keys and string values","Fix the writer (ETL job, other application, manual UPDATE) to emit strict JSON via a real serializer","Pre-validate values on write with a strict parser (see validationCode)","Catch IllegalStateException around the Hibernate read so the bad row fails with a meaningful message instead of breaking hydration blind"],"exampleFix":"-- before: column holds a bare JSON string\nUPDATE entity_table SET json_col = '\"hello\"';\n-- after: object-rooted document\nUPDATE entity_table SET json_col = '{\"msg\":\"hello\"}';","handlingStrategy":"try-catch","validationCode":"// run before storing into a JSON-mapped column\nstatic boolean isStrictJsonRooted(String candidate) {\n    try {\n        com.fasterxml.jackson.databind.JsonNode n =\n                new com.fasterxml.jackson.databind.ObjectMapper().readTree(candidate);\n        return n.isObject() || n.isArray();\n    } catch (Exception e) {\n        return false;\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    return session.createQuery(...).getResultList();\n} catch (IllegalStateException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"unexpected quote read\")) {\n        throw new DataQualityException(\"JSON column holds a non object/array-rooted document\", e);\n    }\n    throw e;\n}","preventionTips":["Only write JSON produced by a real serializer into JSON-mapped columns","Require object or array roots in stored JSON documents","Add a CHECK constraint or write-time validation if multiple applications share the column"],"tags":["hibernate","json","parser","state-machine","malformed-data"],"backgroundTag":"json-parse-error","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}