{"record":{"id":"766dedc9810df4a7","repo":"alibaba/spring-ai-alibaba","slug":"content-type-used-for-store-state-s-is-differen","errorCode":null,"errorMessage":"Content Type used for store state '%s' is different from one '%s' used for deserialize it","messagePattern":"Content Type used for store state '(.+?)' is different from one '(.+?)' used for deserialize it","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/checkpoint/savers/h2/H2Saver.java","lineNumber":289,"sourceCode":"\t\t}\n\t}\n\n\tprivate void executeStatements(Statement statement, String sqlStatements) throws SQLException {\n\t\tfor (String sql : sqlStatements.split(\";\")) {\n\t\t\tif (!sql.isBlank()) {\n\t\t\t\tstatement.execute(sql);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate String encodeState(Map<String, Object> data) throws IOException {\n\t\treturn Base64.getEncoder().encodeToString(stateSerializer.dataToBytes(data));\n\t}\n\n\tprivate Map<String, Object> decodeState(String binaryPayload, String contentType)\n\t\t\tthrows IOException, ClassNotFoundException {\n\t\tif (!Objects.equals(contentType, stateSerializer.contentType())) {\n\t\t\tthrow new IllegalStateException(\n\t\t\t\t\tformat(\"Content Type used for store state '%s' is different from one '%s' used for deserialize it\",\n\t\t\t\t\t\t\tcontentType,\n\t\t\t\t\t\t\tstateSerializer.contentType()));\n\t\t}\n\t\treturn stateSerializer.dataFromBytes(Base64.getDecoder().decode(binaryPayload));\n\t}\n\n\tprivate Checkpoint readCheckpoint(ResultSet resultSet)\n\t\t\tthrows SQLException, IOException, ClassNotFoundException {\n\t\treturn Checkpoint.builder()\n\t\t\t\t.id(resultSet.getString(1))\n\t\t\t\t.nodeId(resultSet.getString(2))\n\t\t\t\t.nextNodeId(resultSet.getString(3))\n\t\t\t\t.state(decodeState(resultSet.getString(4), resultSet.getString(5)))\n\t\t\t\t.build();\n\t}\n\n\t@Override","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/checkpoint/savers/h2/H2Saver.java#L271-L307","documentation":"H2Saver stores serialized checkpoint state with a content type marker. decodeState compares the stored contentType with the current stateSerializer.contentType(); a mismatch means the persisted rows were written with a different serializer configuration than the one used to read them, and deserialization is refused with IllegalStateException.","triggerScenarios":"readCheckpoint() on rows previously written by an H2Saver configured with a different state serializer (different contentType), e.g. after switching from JSON to Java serialization or a custom serializer.","commonSituations":"Upgrading the library or changing serializer config while keeping an old H2 checkpoint database; sharing one checkpoint table across apps with different serializers.","solutions":["Reconfigure the H2Saver to use the same stateSerializer/contentType as when the checkpoints were written","Clear or migrate the old checkpoint data and re-run to regenerate checkpoints","Write a migration that deserializes with the old serializer and re-persists with the new one","Use a fresh H2 database file/table when changing serializer"],"exampleFix":"// before\nH2Saver.builder().stateSerializer(new ObjectStateSerializer()).build(); // data written as JSON\n// after\nH2Saver.builder().stateSerializer(new JacksonStateSerializer()).build(); // matches stored contentType","handlingStrategy":"try-catch","validationCode":"// before reading: check stored contentType column matches serializer.contentType()","typeGuard":"boolean serializerMatches(String storedContentType, StateSerializer s) { return Objects.equals(storedContentType, s.contentType()); }","tryCatchPattern":"try { checkpoint = saver.get(threadId); } catch (IllegalStateException e) { /* serializer mismatch: migrate or recreate checkpoints */ }","preventionTips":["Keep serializer configuration stable across deployments","Include contentType in schema migrations","Use a fresh checkpoint DB when changing serializers"],"tags":["h2","checkpoint","serialization","content-type"],"backgroundTag":"incompatible-source-type","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}