fix(sessions): keep invalid adapter rows out of public listings - #1177
Open
GautamSharma99 wants to merge 1 commit into
Open
fix(sessions): keep invalid adapter rows out of public listings#1177GautamSharma99 wants to merge 1 commit into
GautamSharma99 wants to merge 1 commit into
Conversation
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.
Summary
Validate SessionStore listing rows at the SDK boundary so
list_sessions_from_store()never exposes session IDs that the rest of the SDK rejects.list_sessions()before anyload()calllist_session_summaries()before conversionProblem
Filesystem discovery validates transcript filenames as UUIDs, and individual store-backed lookups reject invalid session IDs. Store-backed listing was the exception: it trusted IDs from adapter indexes and summary sidecars without validation.
That allowed a malformed, stale, or externally populated row to:
store.load()call on the slow pathSDKSessionInfoImplementation
A shared
_has_valid_store_session_id()predicate now checks that a listing row is a dictionary, itssession_idis a string, and the value passes the existing SDK UUID validator.The predicate is applied immediately after each adapter call:
list_sessions()results are filtered before concurrent loadslist_sessions()results are filtered beforeknown_mtimesconstruction and gap-fill slot creationlist_session_summaries()results are filtered before freshness checks,summary_entry_to_sdk_info(), sorting, and paginationFiltering is silent, matching filesystem session discovery, which skips non-UUID transcript filenames rather than failing the entire listing.
The adapter protocol remains unchanged. Stores may still contain externally managed or legacy rows; the public SDK listing simply declines to expose unusable IDs.
Pagination semantics
Invalid rows are removed before sorting, offset, and limit. A malformed row with the newest mtime therefore cannot consume a page position or cause a valid session to be skipped.
Tests
Added regression coverage for:
store.load()limit=1list_sessions()is unavailable for cross-checkingValidation
uv run --extra dev pytest -q— 1297 passed, 5 skippeduv run --extra dev ruff check src tests— passeduv run --extra dev ruff format --check src tests— passeduv run --extra dev mypy src— passedFixes #1167