Skip to content

POST /api/ai: non-string prompt throws unhandled TypeError #12

Description

@royalpinto007

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions