Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect response shape when sending invalid JSON body #2664

Open
OliverJAsh opened this issue Feb 21, 2025 · 0 comments
Open

Incorrect response shape when sending invalid JSON body #2664

OliverJAsh opened this issue Feb 21, 2025 · 0 comments

Comments

@OliverJAsh
Copy link

When sending an invalid JSON body, we get an incorrect response shape.

Current Behavior

$ curl -s 'http://localhost:1234/photos' \
  -H 'content-type: application/json' \
  --data-raw '[' | jq '.'
{
  "error": {
    "code": "invalid_json",
    "message": "Invalid JSON",
    "stack": "Error: Invalid JSON\n    at parseJSON (/Users/oliver/Code/unsplash/unsplash-web/node_modules/.pnpm/[email protected]/node_modules/micri/webpack:/micri/src/body.ts:52:1)\n    at /Users/oliver/Code/unsplash/unsplash-web/node_modules/.pnpm/[email protected]/node_modules/micri/webpack:/micri/src/body.ts:56:1\n    at processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at handler (/Users/oliver/Code/unsplash/unsplash-web/node_modules/.pnpm/@[email protected]/node_modules/@stoplight/prism-http-server/dist/server.js:60:22)",
    "originalError": {}
  }
}

Expected Behavior

A response of the shape described here.


I presume an error is being thrown here and we're not catching it?:

return json(request, { limit: '10mb' });

Related: #1745

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant