Repository navigation
Description
Describe the bug
When JdbcStore.putIfVersion fails for a reason other than a duplicate-key violation, the thrown
exception discards the underlying SQLException's SQLState and message. The operator sees only:
java.lang.IllegalStateException: JdbcStore putIfVersion (insert) failed
Any SQLException whose SQLState is not 23xxx (integrity constraint violation) takes this path
(JdbcStore.java:134-138). That includes common, individually-diagnosable failures:
22001value too long for type character varying(N)42P01undefined table42703undefined column08006connection failure40001serialization failure
The message names no SQLState, no column and no table, and reads like a logic error rather than a
schema/storage error.
Why this matters (not hypothetical)
This is a diagnostics issue, reported separately from the key-length defect that surfaced it. Three
independent reports of the same item_key overflow (#3461, the independent confirmation comment in
#3461, and ours) all had to identify the cause without any help from this message. In our case the
DDL and the real key length only became visible after enabling PostgreSQL statement logging with
log_parameter_max_length_on_error = -1.
#3920 mitigates the pre-existing-narrower-column case with a start-up warning, but the runtime
exception itself is still information-free on main.
To Reproduce
- Use a table where
item_keyisVARCHAR(255)(e.g.dp.agentscope_storeon2.1.0-BETA1). - Call
putIfVersion(namespace, key, value, 0)with a key longer than 255 characters. - The thrown exception reports only
JdbcStore putIfVersion (insert) failed, with no indication
that the cause is a value-length error.
Expected behavior
The exception should include the underlying SQLState and message, preserving the original
SQLException as the cause.
Suggested fix
throw new IllegalStateException(
"JdbcStore putIfVersion (insert) failed [SQLState="
+ e.getSQLState() + "]: " + e.getMessage(),
e);Same treatment for the update path. The parallel throw sites (all still information-free on main)
are:
agentscope-extensions-jdbc/src/main/java/io/agentscope/extensions/jdbc/store/JdbcStore.java:138and:148agentscope-extensions-mysql/src/main/java/io/agentscope/extensions/mysql/store/JdbcStore.java:209and:222agentscope-extensions-postgresql/src/main/java/io/agentscope/extensions/postgresql/store/PostgresBaseStore.java:265and:278
A broader improvement would be to stop converting SQLException into a generic
IllegalStateException (or to introduce an exception type that preserves the SQLState), but adding
the two fields to the message is a strictly better baseline than today.
Environment
- AgentScope-Java Version:
2.1.0-BETA1(tagagentscope-service/service-controlplane/v2.1.0-BETA1, commit5451c73); the same code is present onmain - Java Version: 17
- OS: Windows 11 host with Docker Desktop; Service containers are Linux
- Store:
agentscope-extensions-jdbcagainst PostgreSQL 17 (official compose file)
Activity