Repository navigation
fix(api): answer 400 for a JSON body that is not an object on the logs, settings and providers routes - #16671
Merged
diegosouzapw merged 3 commits intoOct 15, 2026
Conversation
…s, settings and providers routes
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
diegosouzapw
merged commit Oct 15, 2026
7b1b9b2
into
cheaper-inference:release/v3.8.52
48 of 60 checks passed
This was referenced Oct 17, 2026
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
nullJSON body made four management handlers throwCannot read properties of null (reading ...)and the request ended as a 500:POST /api/logs/detail(body.enabled),PATCHandPUT /api/settings(body.expectedRevision, read byparseExpectedRevision;PUTcallsPATCH) andDELETE /api/providers(body.ids).POST /api/logs/detailalso had notry/catcharoundreq.json(), so malformed JSON was an unhandled rejection there, and it answered a string, a number ortruebody with a 200 that switched detailed logs off (settings and providers already answered 400 for those three).Request body must be a JSON objectfor a body that is not an object (andInvalid JSON bodyfor malformed JSON onPOST /api/logs/detail, the message the other routes already use).PATCHandPUT /api/settingsuse the codeINVALID_BODYand emit the same failure audit as their existingINVALID_JSONpath.TypeError, and a non-object body can no longer change the logs setting. This is input validation, not a crash fix: other clients and the process are unaffected either way.Related Issues
logs/detail, fix(providers): add uncloseai gateway entry + allow noauth providers in API + add bun-pack #16430 and feat(factory): integrate Factory AI OAuth subscription and multi-family routing #16156 forproviders, feat(api): authenticate Claude Code to /v1/* with Entra ID SSO #14665 and feat(auth): add native Google and GitHub OAuth login for Dashboard #15153 forsettings) do not validate the body.Target Branch
release/v3.8.xbranch (the highest openrelease/v*), notmainProof Of Fix (required)
tests/unit/mgmt-null-json-body-400.test.tshandler threw (=> 500): Cannot read properties of null (reading 'enabled')(and'expectedRevision'for settingsPATCHandPUT,'ids'for providersDELETE), andexpected 400, got 200for a string, a number ortruebody on/api/logs/detail; 8 of 18 tests fail on the base. The other 10 (string, number andtrueon settings and providers, and an object body on logs) pass on both and pin the behaviour that was already right.Tests Added Or Updated
tests/unit/mgmt-null-json-body-400.test.ts:null, a string, a number andtrueto each of the four handlers and malformed JSON to/api/logs/detailassert a 400; an object body to/api/logs/detailstill answers 200. It reuses the temp data directory harness ofapi-malformed-json-400.test.ts.Coverage Notes
api-malformed-json-400.test.tskeeps passing (23 passed together with the new file).Scope
Validation
api-malformed-json-400pass;check:changelog-integritypasses;prettier --checkis clean on the changed files and eslint reports no new problem.Reviewer Notes
src/app/apithat are safe to call in a test (embeddings, images, audio, moderations, batches, responses input tokens, quota, resilience, the other settings routes) and found no other handler that throws on them; they answer 400 through their zod schemas.POST /v1/filesanswers 500Upload failedfor a non-multipart body; I left it out because it is a wrong content type, not a malformed-JSON case, and it deserves its own decision.