fix(files): drop redundant session_token gate on /api/files/{id} (#568)#575
Merged
Conversation
…568) The 192-bit `sig` token minted at share time is already the auth credential for outbound shared files. Layering the public-chat `require_email` gate on top required a `session_token` that `build_download_url` never appended and that the agent has no way to learn — making file sharing permanently broken for any agent with `require_email=true`. Drops the `_agent_requires_email` import, the gate block, and the `session_token` query parameter from GET/HEAD `/api/files/{id}`. AST-based regression test pins the new shape so the gate cannot silently come back. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
vybe
approved these changes
Apr 29, 2026
vybe
left a comment
Contributor
There was a problem hiding this comment.
LGTM — correct P1 bug fix. Session_token gate was permanently breaking file sharing for require_email agents; sig is the appropriate sole auth credential. Regression test is solid. Approved.
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
/api/files/{id}was double-gating downloads: the 192-bitsigtoken (sole credential the agent can mint and pass to the recipient) plus asession_tokenenforced when the agent hadrequire_email=true.build_download_urlnever appendedsession_token, so file sharing was permanently broken for anyrequire_emailagent — every link returned401 session_token required._agent_requires_emailimport, the gate block, and thesession_tokenquery param from GET/HEAD/api/files/{id}. Thesigis a 192-bit one-time token minted at share time and constant-time compared; layering the channel-access gate on top added no real auth and broke the feature.tests/unit/test_file_download_no_session_gate.py) that pins the new shape — fails if the gate, the import, or the param ever come back.Closes #568.
Test plan
pytest unit/test_file_download_no_session_gate.py— 5/5 passpytest unit/test_agent_shared_files_migration.py unit/test_file_sharing_mixin.py— green🤖 Generated with Claude Code