hibernate/hibernate-orm · error · IllegalStateException
Unrecognized marker: {}
Error message
Unrecognized marker: {} What it means
In the OTHER-marker branch, consumeNonStringValue() scans the unquoted literal (expected to be true, false, null or a number) and returns -1 when it reaches the end of input without ever hitting a delimiter (whitespace or a structural marker like } ] , :). The reader then reports the character at the current position as an 'Unrecognized marker'. In practice the JSON is truncated in the middle of (or right after) a bare value, or has garbage trailing characters.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/type/format/StringJsonDocumentReader.java:210
throw new IllegalStateException( "unexpected quote read in current processing state " +
this.processingStates.getCurrent() );
}
case KEY_VALUE_SEPARATOR: // that's the start of an attribute value
//assert this.processingStates.getCurrent() == JsonProcessingState.OBJECT_KEY_NAME;
// flush the OBJECT_KEY_NAME
//this.processingStates.pop();
break;
case SEPARATOR:
// unless we are processing an array, following SEPARATOR that will a key
break;
case OTHER:
// here we are in front of a boolean, a null or a numeric value.
// if none of these cases we're going to raise IllegalStateException
// put back what we've read
moveBufferPosition(-1);
final int valueSize = consumeNonStringValue();
if (valueSize == -1) {
throw new IllegalStateException( "Unrecognized marker: " + StringJsonDocumentMarker.markerOf(
this.jsonString.charAt( this.position )));
}
switch ( this.processingStates.getCurrent() ) {
case ARRAY:
case OBJECT:
return getUnquotedValueType(this.jsonString.charAt( this.jsonValueStart));
default:
throw new IllegalStateException( "unexpected read ["+
this.jsonString.substring( this.jsonValueStart,this.jsonValueEnd )+
"] in current processing state " +
this.processingStates.getCurrent() );
}
default: {
throw new IllegalStateException( "unexpected marker ["+
marker +
"] at position " + this.position );
}
}View on GitHub (pinned to fad1729dce)
Solutions
- Retrieve the full failing column value and check its tail for truncation or appended garbage; repair it
- Widen the column / fix the producer so complete JSON is stored
- Validate on write with a strict parser so truncated values never reach the database
- Catch IllegalStateException during bulk reads to quarantine bad rows
Example fix
-- before: value truncated by a too-narrow column ('{"a": tru')
ALTER TABLE entity_table ALTER COLUMN json_col TYPE text;
UPDATE entity_table SET json_col = '{"a": true}';
-- after: complete document stored Defensive patterns
Strategy: try-catch
Validate before calling
static void assertCompleteJson(String candidate) {
try {
new com.fasterxml.jackson.databind.ObjectMapper().readTree(candidate);
} catch (Exception e) {
throw new IllegalArgumentException("Refusing to store truncated/invalid JSON: " + e.getMessage(), e);
}
} Try / catch
try {
results = query.getResultList();
} catch (IllegalStateException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Unrecognized marker")) {
logQuarantineRow(e); // isolate the bad row instead of failing the whole load
return List.of();
}
throw e;
} Prevention
- Size JSON columns generously (text/jsonb, not narrow varchar)
- Validate with a strict parser before every write to the column
- Write JSON within the same transaction as the owning row so partial values never become visible
When it happens
Trigger: Documents like {"a": tru (literal cut off at end of input), [123 (bare number running to the limit), or {"a":1}xyz where trailing non-marker text extends to the end of the string so no delimiter is ever found.
Common situations: Column value truncated by an ETL/transport layer or manual editing; a VARCHAR column too short for the JSON so it was silently cut; another writer appending diagnostics text after the JSON; reading a partially-written value because the writer had no transactional protection.
Related errors
- unexpected end of JSON [{}] in current processing state {}
- unexpected quote read in current processing state {}
- unexpected read [{}] in current processing state {}
- Can't find ending quote of key name
- Expected JSON object end, but none found.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/7925a569d0754fa4.
Report an issue: GitHub.