Skip to content

Fix malformed inference form JSON returning 500#7509

Open
fallintoplace wants to merge 1 commit into
tensorzero:mainfrom
fallintoplace:fix/inference-json-400
Open

Fix malformed inference form JSON returning 500#7509
fallintoplace wants to merge 1 commit into
tensorzero:mainfrom
fallintoplace:fix/inference-json-400

Conversation

@fallintoplace
Copy link
Copy Markdown

Summary

Fixes /api/tensorzero/inference so malformed JSON in the data form field returns 400 Bad Request instead of a generic 500 Server error.

Details

The route used native JSON.parse(data) but only handled the custom JSONParseError type. Native JSON.parse throws SyntaxError, so malformed JSON fell through to the generic server-error response.

This change parses data in a dedicated try/catch and returns the existing parse-error response with status 400.

Fixes #7508

Tests

  • npx --yes pnpm@10.33.0 exec vitest run app/routes/api/tensorzero/inference.test.ts
  • npx --yes pnpm@10.33.0 run format
  • npx --yes pnpm@10.33.0 run lint
  • npx --yes pnpm@10.33.0 --filter=@tensorzero/tensorzero-node build
  • npx --yes pnpm@10.33.0 run typecheck

@tensorzero-cla-bot
Copy link
Copy Markdown

tensorzero-cla-bot Bot commented May 22, 2026

✅ All contributors to this pull request have signed the TensorZero CLA. Thank you!

@fallintoplace
Copy link
Copy Markdown
Author

I have read the Contributor License Agreement (CLA) and hereby sign the CLA.

tensorzero-cla-bot Bot added a commit that referenced this pull request May 22, 2026
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

Successfully merging this pull request may close these issues.

UI: malformed /api/tensorzero/inference form JSON returns 500 instead of 400

1 participant