Skip to content

Bug: emailed attachments are not indexed or retrievable on the Postgres backend #3121

Closed

Description

@Israeltheminer

An email attachment is never indexed on 0.5, so chat cannot find anything inside one. The four PRs that built this (#3011, #3012, #3014, #3062) are merged and unreachable — they live in convex/, which the 0.5 backend only reaches through the shim.

Why

Three separate cuts, each deliberate and each recorded in the code:

The bind stops short of indexing. backend/domains/conversations/shim.ts:546 says it: "the 0.4 conversation-scope RAG upgrade rides the conversation-corpus retrieval leg (still honest-empty in 0.5) — bound, never queued here." So #3010's binding works and #3012's indexing does not.

The retrieval gate has no conversation branch. backend/domains/knowledge/service.ts decides a ref on documentId or threadId only. Its SELECT does not read fm.conversation_id, even though 0037_conversation_attachments.sql adds the column. A conversation-scoped row would fall through to the same-org fallback, which is the posture #3011 was written to prevent.

Message refs are refused outright. service.ts:107: if (ref.startsWith('msg:')) { continue; } — the whole of #3062.

backend/MIGRATION.md lists "conversation/email retrievable branches" as PENDING on the knowledge row, so this is deferred work rather than a porting slip.

What still works

bindFileToConversation binds, so #3010 is live. The Documents-side listings from #3033 and #3035 read file_metadata directly and are unaffected. Conversation search (#3006, #3084) searches subjects, contacts and message bodies in SQL, not the corpus, and is unaffected.

The gap is retrieval of attachment CONTENT: a CV, a signed contract, a spreadsheet someone emailed in.

Scope

Three pieces, in the order #3011 and #3012 shipped them:

  1. Carry conversation_id through the corpus write and the SQL scope clause, and add the conversation branch to filterRetrievableRagFileIds, decided by conversationAssignmentAllows — the predicate already ported to backend/domains/conversations.
  2. Queue on bind, in the bind's own transaction. fix(platform): stop email attachments starving the RAG indexing cap #2995 is the record of what splitting that promise across a boundary costs.
  3. Restore the msg: branch once something writes a message ref.

#3015 step 3 (index email bodies) depends on all three and should not start before them.

Not a security exposure. Nothing indexes these files, so no corpus rows exist to leak — the fallback is unreachable today. It becomes reachable the moment step 2 lands, so step 1 ships first.

Activity

  1. Israeltheminer commented on Sep 4, 2026

    @Israeltheminer
    ContributorAuthor

    Step 1 is #3220 — the conversation retrievable branch.

    The write side was already there: core/knowledge/indexing.ts stamps conversation_id and its comment says why. What was missing is exactly what this issue says: the SELECT read thread_id only, and decideRetrievable had no conversation branch.

    The decision is assignment privacy rather than org scope, so it delegates to conversationAssignmentAllows instead of restating it, and resolves the allowed set from the candidates' conversations — an admin may read every conversation, so enumerating theirs would ship thousands of ids into every dispatch.

    Steps 2 and 3 are unblocked and left for their own changes, in the order this issue sets out.

  2. yannickmonney commented on Sep 27, 2026

    @yannickmonney
    Contributor

    Fixed in two steps: #3220 added the conversation retrievable branch, and #3225 (50db977) makes bindFileToConversation enqueue rag.index_file inside the bind transaction; chat retrieval has a mail-attachment leg. Step 3 (msg: refs) only applies once message bodies are indexed, which #3015 tracks. Attachments bound before #3225 are deliberately not backfilled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions