Skip to content

fix(files): drop redundant session_token gate on /api/files/{id} (#568)#575

Merged
vybe merged 1 commit into
devfrom
feature/568-file-sharing-require-email
Apr 29, 2026
Merged

fix(files): drop redundant session_token gate on /api/files/{id} (#568)#575
vybe merged 1 commit into
devfrom
feature/568-file-sharing-require-email

Conversation

@dolho

@dolho dolho commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • /api/files/{id} was double-gating downloads: the 192-bit sig token (sole credential the agent can mint and pass to the recipient) plus a session_token enforced when the agent had require_email=true. build_download_url never appended session_token, so file sharing was permanently broken for any require_email agent — every link returned 401 session_token required.
  • Removes the _agent_requires_email import, the gate block, and the session_token query param from GET/HEAD /api/files/{id}. The sig is 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.
  • Adds an AST-based regression test (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 pass
  • pytest unit/test_agent_shared_files_migration.py unit/test_file_sharing_mixin.py — green

🤖 Generated with Claude Code

…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>
@dolho
dolho requested a review from vybe April 29, 2026 08:40

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vybe
vybe merged commit 7f09aa7 into dev Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants