File Search worker finds no work when the database user has neither superuser nor BYPASSRLS

Aperta
#1,418 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
postgresql, typescript
Ambito
backend, database

Direzione di ricerca

Start with FileSearchRepository.withTenant and the worker's cross-workspace queries: scheduler lease claim, extend and release, the share sweep, and closing interrupted runs (#1417), none of which set app.current_org. Check the existing org_isolation policies on the file_* tables, then add a migration with a maintenance switch such as app.files_maintenance. Done means the worker finds work and sweeps shares under a non-superuser role without BYPASSRLS, covered by an integration test modeled on the #1395 CREATEROLE check.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

The file_* tables use FORCE ROW LEVEL SECURITY; tenant queries go through FileSearchRepository.withTenant (app.current_org, optionally SET LOCAL ROLE amcp_files). The worker's cross-workspace maintenance queries do not set app.current_org:

  • scheduler lease claim, extend and release;
  • share sweep;
  • closing interrupted runs (#1417).

They rely on the application user bypassing RLS: superuser, which is the case on AnythingMCP Cloud and in the default Docker Compose setup.

On a self-hosted install whose application user is neither superuser nor BYPASSRLS (some managed PostgreSQL offerings), those queries see no rows. Syncs then never start, and expired share files are not swept. Nothing errors.

Proposal

  • A new migration extends the org_isolation policies with an explicit maintenance switch, for example OR current_setting('app.files_maintenance', true) = 'on'.
  • The worker's cross-workspace queries run inside a transaction with set_config('app.files_maintenance', 'on', true).
  • Add an integration test as a non-superuser role, like the one used for #1395's CREATEROLE check.

Found while hardening File Search on 2026-11-01. Relates to #1379, #1380, #1383.

Lingua principale
TypeScript
Stelle
856
Fork
82
Merge medio
6h 43m
PR unite (30g)
399

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di HelpCode-ai/anythingmcp

Tutte le issue di HelpCode-ai/anythingmcp

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.