feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes

This commit is contained in:
Yun Chan 2026-11-14 11:51:41 +09:00
parent 01ef3293cf
commit 66b6b45ba9
399 changed files with 17828 additions and 11330 deletions

View file

@ -5,7 +5,7 @@
// OpenAI. index.ts wires the real adapters.
import { handleCorsPreflightRequest } from '../_shared/cors.ts'
import { errorResponse, jsonResponse as json } from '../_shared/json-response.ts'
import { errorResponse, JsonBodyError, jsonResponse as json, readJsonBody } from '../_shared/json-response.ts'
import { type EmbeddingProvider, isEmbedding } from '../_shared/openai-embeddings.ts'
import {
EMBEDDING_LIMITS,
@ -95,7 +95,16 @@ export function createEmbedChunksHandler(deps: EmbedChunksDeps): (req: Request)
try {
const user = await deps.authenticate(req)
const body = await req.json().catch(() => null) as { document_id?: unknown } | null
let body: { document_id?: unknown } | null = null
try {
body = await readJsonBody(req, { maxBytes: 16 * 1024, requirePlainObject: true }) as {
document_id?: unknown
}
} catch (error) {
if (error instanceof JsonBodyError && error.status === 413) {
return json(413, { error: 'request_too_large' })
}
}
if (!body || typeof body.document_id !== 'string' || !UUID_PATTERN.test(body.document_id)) {
return json(400, { error: 'invalid_document_id' })
}