Fix: bruk sql.json() for JSONB payload i job_queue

JSON.stringify + ::jsonb via postgres-biblioteket lagret payload som
dobbelt-escaped string i stedet for JSONB-objekt. Workeren fant ikke
message_id i den resulterende strengen.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
vegard 2026-03-16 03:10:08 +01:00
parent 832ea7117a
commit 0a560bdf2d

View file

@ -30,17 +30,18 @@ export const POST: RequestHandler = async ({ request, locals }) => {
if (!msg) error(404, 'Melding ikke funnet');
// Opprett jobb i køen
const payload = {
message_id,
action: action ?? 'fix_text',
prompt_override: prompt_override ?? null,
model: model ?? null
};
const [job] = await sql`
INSERT INTO job_queue (workspace_id, job_type, payload, priority)
VALUES (
${workspace.id},
'ai_text_process',
${JSON.stringify({
message_id,
action: action ?? 'fix_text',
prompt_override: prompt_override ?? null,
model: model ?? null
})}::jsonb,
${sql.json(payload)},
10
)
RETURNING id, status, created_at