fix(desktop): drop manual Content-Length in OAuth net.request (ERR_INVALID_ARGUMENT) - #40174
Closed
Kyzcreig wants to merge 1 commit into
Closed
fix(desktop): drop manual Content-Length in OAuth net.request (ERR_INVALID_ARGUMENT)#40174Kyzcreig wants to merge 1 commit into
Kyzcreig wants to merge 1 commit into
Conversation
…VALID_ARGUMENT) Electron's net.request (ClientRequest, Chromium net stack) treats Content-Length as a protected header it computes itself from request.write(body). Setting it explicitly throws net::ERR_INVALID_ARGUMENT and the request fails before leaving the app. This only affected the OAuth/remote path (fetchJsonViaOauthSession via electronNet) on body-bearing POSTs — most visibly POST /api/model/set from Settings -> Models 'Apply', which surfaced as "Error invoking remote method 'hermes:api': Error: net::ERR_INVALID_ARGUMENT". GET and bodyless POSTs were unaffected, and the local/token path (fetchJson via Node http) tolerates a manual Content-Length, so it regressed only for remote-backend OAuth users. Verified empirically with a headless Electron net.request probe: WITH Content-Length -> net::ERR_INVALID_ARGUMENT WITHOUT Content-Length -> net::ERR_UNSAFE_PORT (header validation passed) Introduced in NousResearch#39921.
tonydwb
approved these changes
Jun 6, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Approved. Drops manual Content-Length header in desktop OAuth net.request to fix ERR_INVALID_ARGUMENT.
Closed
1 task
Contributor
Author
|
Closing as implemented on current |
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.
Changing the model from the desktop app Settings → Models → Apply (and any other body-bearing POST) fails for remote-backend OAuth users with:
Root cause
fetchJsonViaOauthSession()inapps/desktop/electron/main.cjsmanually setsContent-Lengthon the Electronnet.request:Electron's
net.request(ClientRequest, Chromium net stack) treatsContent-Lengthas a protected header it computes itself fromrequest.write(body). Setting it explicitly throwsnet::ERR_INVALID_ARGUMENT, so the request fails before it ever leaves the app.This only bit the OAuth/remote path (
electronNet) on body-bearing POSTs (e.g.POST /api/model/set). GET and bodyless POSTs were unaffected, and the local/token path (fetchJson, Nodehttp) tolerates a manualContent-Length— which is why it regressed only for remote-backend OAuth users. Introduced in #39921.Empirical verification
Headless Electron
net.requestprobe (Electron 40):Fix
Remove the manual
Content-Lengthheader; let Electron compute it fromrequest.write(body). The backendPOST /api/model/setwas verified to return 200 for the same payload, confirming the failure was entirely client-side.