PostgresBaseStore UPSERT_SQL has an extra comma and fails updates
Bug
PostgresBaseStore.UPSERT_SQL contains an extra comma after the version assignment:
ON CONFLICT (namespace_path, item_key) DO UPDATE SET
value_json = EXCLUDED.value_json,
version = %1$s.version + 1,,
updated_at = EXCLUDED.updated_at
The ,, makes every update of an existing key through BaseStore.put(...) invalid PostgreSQL syntax. This blocks the official PostgresDistributedStore remote-filesystem/state composition and cross-replica production acceptance.
Observed against e3a412ed2cc944e401da861c8d5e464b967724e9 in:
agentscope-extensions-postgresql/.../store/PostgresBaseStore.java
Expected fix
Remove the extra comma and add a real PostgreSQL integration test that proves:
- first
putinserts version 1; - second
putupdates value and version to 2; - two independent clients using the same stale version with
putIfVersionaccept exactly one writer; - namespace isolation/search/delete remain correct;
PostgresDistributedStorefresh-client state, BaseStore, snapshot and execution-guard composition works.
A source-only SQL assertion is not sufficient; the regression should execute against PostgreSQL because formatting/table-name substitution and transaction behavior are part of the contract.
Impact
Applications selecting the newly released PostgreSQL distributed Harness state can initialize schemas and perform an initial insert, but normal overwrite/update through BaseStore.put fails at runtime. Product hosts should not patch or replace the official BaseStore, so production readiness must remain false until the extension is fixed.
🤖 AI Assessment: Bug Report
Classification: Bug (area/harness, postgresql)
Analysis: This is a valid bug. The extra comma in UPSERT_SQL causes PostgreSQL syntax errors.
Related PR: #2167 (fix PostgreSQL upsert SQL syntax error) fixes this issue.
Next Steps: Review and merge #2167.
Automated assessment by github-manager
I'd like to work on this fix. Plan: remove the extra comma in PostgresBaseStore.UPSERT_SQL and add a PostgreSQL regression test covering put/update version bump and putIfVersion conflict behavior.
Looks like this was already fixed in #2167 (fix PostgreSQL upsert SQL syntax error (#2166)). On current main, UPSERT_SQL no longer has the double comma:
version = %1$s.version + 1,
I'll step back from this issue — maintainers may want to close it as a duplicate of #2166.