hibernate/hibernate-orm · error · IllegalStateException

unexpected marker [{}] at position {}

Error message

unexpected marker [{}] at position {}

What it means

Defensive default arm of the marker switch in next(): it fires only when the parsed StringJsonDocumentMarker has no matching case in the switch. The current enum contains exactly the eight markers that are all handled, so this branch is effectively unreachable through normal parsing; hitting it indicates an internal invariant break (or a Hibernate change that added a marker without a case).

Source

Thrown at hibernate-core/src/main/java/org/hibernate/type/format/StringJsonDocumentReader.java:224

					// 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 );
				}
			}
		}
		throw new IllegalStateException( "unexpected end of JSON ["+
										this.jsonString.substring( this.jsonValueStart,this.jsonValueEnd )+
										"] in current processing state " +
										this.processingStates.getCurrent() );
	}

	/**
	 * Gets the type of unquoted value.
	 * We assume that the String value follows JSON specification. I.e unquoted value that starts with 't' can't be anything else
	 * than <code>true</code>
	 * @param jsonValueChar the value
	 * @return the type of the value
	 */

View on GitHub (pinned to fad1729dce)

Solutions

  1. Capture the full stack trace and the exact JSON payload that triggered it
  2. Verify the hibernate-core version in the classpath is a coherent release (no mixed jars) and test against the latest patch release
  3. Report to Hibernate JIRA (HHH) with the entity mapping, dialect, and the JSON value
Defensive patterns

Strategy: try-catch

Try / catch

try {
    results = query.getResultList();
} catch (IllegalStateException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("unexpected marker [")) {
        // internal invariant break: capture payload + hibernate version for a bug report
        log.error("Hibernate JSON reader invariant broken", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Not reachable via the public API with current enum values; would require corrupted reader state, concurrent misuse of one reader instance, or a patched/newer hibernate-core that introduced an unhandled marker.

Common situations: Essentially never seen in the field; if it appears it accompanies a modified hibernate-core build or an upstream regression.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/5844b6b50ebb3582. Report an issue: GitHub.