Repository navigation
fix(gkb): a global contribution is never matched as a document without a workspace - #532
Conversation
…t a workspace A global contribution and a document uploaded without a workspace both have workspace_id NULL. documents.exists(filename, None) matched both, so an admin upload naming no workspace, an admin's workspace-less connector, or the re-ingest worker could update a contribution in place, and every workspace reads the tier. documents.stale() also returned contributions, which have no source file to re-read. Both now skip rows with contributed_at set. Found by the separate review of #528. The integration test fails on the old code with (True, True). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KkWPqAcWbxfqz1aCP6Qsdx
|
Security review (separate agent session, CONTRIBUTING.md)Reviewed: PR #532 at Verdict: the fix is correct and narrow. Both queries that treated "no workspace" as one bucket now exclude the global tier. No other query in Checklist
Related paths checked, no finding
FindingsLow: the regression test has no positive control. The test asserts
🤖 Generated with Claude Code |



What
A follow-up from the separate security review of #528 (Low, reachable by a global admin and the SyncWorker only).
A global contribution and a document uploaded without a workspace both carry
workspace_id IS NULL. As a result:documents.exists(filename, None), withIS NOT DISTINCT FROM, matched a contribution. An admin upload naming no workspace, an admin-created connector without a workspace, or the re-ingest worker could therefore update a contribution in place. Every workspace reads the global tier.documents.stale()returned contributions too, so the worker tried to re-ingest a copy that has no source file.Change
contributed_at IS NULL.Tests
test_a_contribution_is_not_mistaken_for_a_document_without_a_workspaceintests/integration/test_gkb_contribution.py. Against Postgres it fails on the old code with(True, True):existsmatched the contribution, andstalereturned it.test_db_operationspass: 39 passed. ruff is clean.touches the global tier→ security-critical per CONTRIBUTING, so it gets a separate review.🤖 Generated with Claude Code
https://claude.ai/code/session_01KkWPqAcWbxfqz1aCP6Qsdx