fix(api): wait for knowledge dispatch and encode filenames - #6583
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryHigh Risk Overview Processing is now enqueued in the same transaction as document creation via a new outbox event. The outbox handler redispatches work, reclaiming abandoned claims after a 10-minute stale threshold. Processing writes use Uploads no longer use a separate v2 Also surfaces typed Reviewed by Cursor Bugbot for commit 1e45e2b. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThe PR moves direct knowledge-document processing onto a transactional outbox, adds stale processing-claim recovery, and hardens download filename encoding.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/knowledge/application/documents.ts | Moves knowledge-file persistence and reauthorization into the application use case and registers durable processing intent with document creation. |
| apps/sim/lib/knowledge/documents/service.ts | Atomically persists processing outbox events and adds timestamp-guarded processing commits that prevent reclaimed workers from writing output or billing. |
| apps/sim/lib/knowledge/documents/processing-claim.ts | Adds stale-claim reclamation and failure transitions guarded by the original processing timestamp. |
| apps/sim/lib/knowledge/documents/processing-outbox-handler.ts | Dispatches durable processing events while retrying active claims and reclaiming abandoned ones after the shared threshold. |
| apps/sim/app/api/v2/files/[fileId]/route.ts | Replaces ad hoc Content-Disposition construction with the shared hardened filename encoder. |
| apps/sim/lib/api/server/routes/v2-body-lifecycle-route.ts | Removes the generic transfer stage now that upload persistence occurs inside the authorized application operation. |
Sequence Diagram
sequenceDiagram
participant API as Upload API
participant Storage as Object Storage
participant DB as Database
participant Outbox as Outbox Worker
participant Queue as Processing Queue
API->>Storage: Store knowledge document
API->>DB: Begin registration transaction
DB->>DB: Create document and account storage
DB->>DB: Insert processing outbox event
DB-->>API: Commit
API-->>API: Return success
Outbox->>DB: Claim outbox event
Outbox->>Queue: Dispatch document processing
Queue->>DB: Claim document with timestamp token
Queue->>DB: Commit output if token still matches
Reviews (8): Last reviewed commit: "fix(knowledge): restore processing takeo..." | Re-trigger Greptile
|
@cursor review |
|
@cursor review |
c7b3b51 to
f95af77
Compare
|
@cursor review |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 21b71bc. Configure here.
9e8050b to
47ee4c3
Compare
|
@cursor review |
47ee4c3 to
5d95ca8
Compare
|
@cursor review |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5d95ca8. Configure here.
|
@cursor review |

Summary
Type of Change
Testing
bun run lintandbun run lint:checkpassedbun run check:auditspassedChecklist