Skip to content

Commit 589e337

Browse files
committed
fix(rag): return 200 for partial indexing
1 parent 6ccdde3 commit 589e337

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

docs/specs/active/0018-spec-rag-retriever-indexer.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ Index documents with automatic chunking and embedding generation.
7676
}
7777
```
7878

79+
**Status codes:**
80+
81+
- Always returns `200 OK`, including partial indexing; inspect `success` and `failed` for per-item status.
82+
7983
### POST /api/rag/search
8084

8185
Search documents with hybrid retrieval and optional reranking.

src/app/api/rag/index/route.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import { indexDocuments } from "@/lib/rag/indexer";
1919
* Index documents into the RAG store with automatic chunking and embedding.
2020
*
2121
* @param req - Request with documents array.
22-
* @returns Index result with counts and failed documents. Uses HTTP 207
23-
* (Multi-Status) when indexing partially succeeds.
22+
* @returns Index result with counts and failed documents. Always returns HTTP 200;
23+
* partial success is conveyed via `success: false` and per-item failures.
2424
*
2525
* @example
2626
* ```bash
@@ -49,7 +49,5 @@ export const POST = withApiGuards({
4949
supabase,
5050
});
5151

52-
return NextResponse.json(result, {
53-
status: result.success ? 200 : 207, // 207 Multi-Status for partial success
54-
});
52+
return NextResponse.json(result, { status: 200 });
5553
});

src/lib/rag/__tests__/reranker.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ describe("TogetherReranker", () => {
117117

118118
expect(mockRerank).toHaveBeenCalledWith(
119119
expect.objectContaining({
120-
topN: 1, // Should cap topN by config topN
120+
topN: 1, // Should use min(requested topN, documents.length, config.topN)
121121
})
122122
);
123123
expect(result).toHaveLength(1);

0 commit comments

Comments
 (0)