Problem
{prompt: 123} throws TypeError: prompt.trim is not a function (HTTP 500): only falsy prompts are rejected, non-string truthy ones crash.
Where
app/api/ai/route.ts (if (!prompt) then prompt.trim()).
Acceptance
Add a failing route test first posting {prompt: 123}, expecting 400. Then add a typeof prompt !== "string" guard.
Problem
{prompt: 123}throwsTypeError: prompt.trim is not a function(HTTP 500): only falsy prompts are rejected, non-string truthy ones crash.Where
app/api/ai/route.ts(if (!prompt)thenprompt.trim()).Acceptance
Add a failing route test first posting
{prompt: 123}, expecting 400. Then add atypeof prompt !== "string"guard.