fix(harness): use ':' separator in sandbox slot session id so SQL stores accept it#2336
Open
logicwu0 wants to merge 1 commit into
Open
Conversation
…res accept it SessionSandboxStateStore.slotSessionId() encoded the isolation key with '/' (e.g. "sandbox/session/<id>"). That value is passed as the sessionId to the backing AgentStateStore, but SQL-backed stores reject '/' and '\' in validateSessionId (PostgresAgentStateStore, MysqlAgentStateStore), so sandbox state persistence threw IllegalArgumentException on those backends under every isolation scope — not just Postgres. Switch the segment separator from '/' to ':', matching the convention MysqlAgentStateStore#slotId already relies on for the same reason. Single producer-side change fixes all backing stores at once. Add a regression test using a store that mirrors the validateSessionId contract, covering SESSION/USER/AGENT/GLOBAL scopes (RED before the fix, GREEN after).
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
2.0.1-SNAPSHOT (main); bug also present in 2.0.0.
Description
Fixes #2327.
Background.
SessionSandboxStateStore.slotSessionId()packs the sandboxSandboxIsolationKeyinto a single sessionId string using/as the segment separator (e.g.sandbox/session/<id>,sandbox/user/<agentId>/<id>,sandbox/agent/<agentId>,sandbox/global). That string is then passed as thesessionIdargument to the backingAgentStateStore.Problem. SQL-backed stores validate the sessionId and reject
/and\as path separators —PostgresAgentStateStore.validateSessionIdandMysqlAgentStateStore.validateSessionIdboth throwIllegalArgumentExceptionin that case. As a result, sandbox state persistence fails on every SQL backend under anyIsolationScope(SESSION/USER/AGENT/GLOBAL). The original issue reported Postgres, but MySQL is affected too: itsslotId()uses:only to joinuserId/sessionId, so it cannot dodge the/that already lives inside the sandbox slot's sessionId.Fix. Switch the slot-id segment separator from
/to:. This is exactly the conventionMysqlAgentStateStore#slotIdalready relies on (and documents) for the samevalidateSessionIdreason, so it stays consistent with the codebase. The change is on the producer side (SessionSandboxStateStore), so it fixes all backing stores at once; no store-specific changes needed. No code reverse-parses these slot strings on/, so changing the separator is safe.How to test. Added
slotSessionId_hasNoPathSeparators_soSqlStoresAccept_allScopesinSessionSandboxStateStoreTest. It drives the store through a backend that mirrors thevalidateSessionIdcontract (rejects//\) and round-trips save/load/delete for all four isolation scopes. It fails (RED) with the old/separators —IllegalArgumentException: ... cannot contain path separators: sandbox/session/sess-001, the same error seen on Postgres/MySQL — and passes (GREEN) with the fix. The pre-existing tests (which useInMemoryAgentStateStore, no validation) are unchanged.mvn -pl agentscope-harness test: all green;spotless:checkclean.Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)