Repository navigation
fix(api): answer 400 for a non-JSON body on POST /api/chaos/run and POST /api/skills/collect/chaos - #16991
Merged
diegosouzapw merged 2 commits intoOct 18, 2026
Conversation
…OST /api/skills/collect/chaos
diegosouzapw
merged commit Oct 18, 2026
6ce866c
into
cheaper-inference:release/v3.8.52
41 of 60 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /api/chaos/runandPOST /api/skills/collect/chaosread the body withawait request.json()inside thetrywhosecatchanswers 500, so a body that is not JSON came back as a 500. Both now answer 400 with{ "error": { "message": "Invalid JSON body" } }, the error envelope these routes already use. A well-formed body behaves as before.Related Issues
Target Branch
release/v3.8.xbranch (release/v3.8.52), notmainValidation
chaos-api-routes,chaos-executor,chaos-configand the new file: 30 tests).prettier --checkandeslinton the changed files are clean;check:ai-attributionandcheck:changelog-integritypass.Tests Added Or Updated
tests/unit/chaos-malformed-json-400.test.ts(new): a body that is not JSON sent to each route, with Chaos Mode enabled and, for the external route, an API key withchaosModeEnabled, must answer 400 withInvalid JSON body; a well-formed but invalid body must still answer 400 as before. On the base the two non-JSON cases fail with500 !== 400; with the change they pass.Coverage Notes
src/; the new test calls the handlers directly, with the same setup aschaos-api-routes.test.ts. I did not run the routes under the Next.js server./api/chaos/run) or after the API key is verified (/api/skills/collect/chaos), so a caller that is not allowed still gets 401, 403 or the "not enabled" 400 first.Reviewer Notes
changelog.d/fixes/PENDING-chaos-json-400.md, one line, left for you to rename.