Repository navigation
fix(public-chat): an anonymous session finds its own history after a reload (#3443) - #3477
Merged
Merged
Conversation
…n, so history survives a reload (#3443) get_or_create_session stores an identifier verbatim unless it is an email, but get_session_by_identifier lowercased its argument unconditionally. An anonymous identifier is a mixed-case secrets.token_urlsafe(16) token, so the lookup behind GET /api/public/history/{token} and DELETE /api/public/session/{token} never matched the row the chat turn had just written: history came back empty after every reload, and "New conversation" cleared nothing. Where two tokens differed only in case, the mixed-case visitor was handed the lowercase visitor's session. The lookup now matches the exact string first and reaches a row through its lowercased form only when that row is identifier_type = 'email', which keeps email lookups case-insensitive. One SQLAlchemy Core implementation serves both SQLite and PostgreSQL; both route callers already pass the anonymous token unmodified, so no caller changes. Tests: tests/unit/test_3443_public_chat_history_lookup.py. With the fix reverted, three go red: test_mixed_case_anonymous_token_finds_its_own_session, test_anonymous_tokens_differing_only_in_case_stay_separate and test_anonymous_lookup_is_not_case_insensitive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # tests/registry.json
Contributor
|
merge-train (2026-10-10): merged |
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.
Description
get_session_by_identifierlowercased its argument unconditionally, whileget_or_create_sessionstores an anonymous token verbatim, so a mixed-case anonymous id never matched its own row — history never restored and New conversation cleared nothing. The lookup now matches the exact string first and falls back to the lowercased form only against rows withidentifier_type = 'email', so email lookups stay case-insensitive.Part of the UI sweep epic #3471.
Related Issue
Fixes #3443
Journey Impact
Journey Impact: none: bug fix to existing behaviour found by the UI sweep; no journey promise is added or changed
Type of Change
Testing
Mutation:
tests/unit/test_3443_public_chat_history_lookup.py— 3 red with the fix stashed (test_mixed_case_anonymous_token_finds_its_own_session,test_anonymous_tokens_differing_only_in_case_stay_separate,test_anonymous_lookup_is_not_case_insensitive); restored byte-identical. SQLite leg only; the PostgreSQL leg of the harness was not run locally.UI verification: on an isolated stack built from this change with a seeded link, a mixed-case anonymous session and two stored messages (user + assistant):
GET /api/public/history/<token>?session_id=<mixed-case id>returns both messages and the page renders them; the lowercased id gives an empty conversation. The seeded agent had no container, so the page's availability gate was bypassed in the browser to reach the history call — a full reload against a running agent with a real reply was not exercised.Checklist
🤖 Generated with Claude Code