Repository navigation
fix(server): stop writing a second response after a failed upgrade - #7563
Conversation
This comment has been minimized.
This comment has been minimized.
d829cc3 to
c638453
Compare
|
/review |
|
Claude finished @geovannewashington's task in 2m 43s —— View job Code Review CompleteReviewed 4 files on all three axes: Standards (repo rules, language conventions, tests, code smells), Spec (does it implement shellhub-io/team#346?) and Correctness (security and runtime defects). No new issues found. The code looks good as-is. The earlier judgement call about the duplicated |
gorilla's Upgrade writes its own error response, so the handlers' second write only appended the raw error to the body and the cause never reached the logs. The handlers now log it and return nil, since an error would make Echo write again. Revdial resolves its dialer before the upgrade to log through it, so a non-Dialer entry now gets a 400 instead of an upgraded connection that is closed at once. It ignores Load's ok because the type assertion on the nil a missing key yields fails too. Its test reports a failed pickup to end the dial the bad request left waiting. Fixes: shellhub-io/team#346
c638453 to
80a4c7d
Compare
Summary
Revdial now resolves its dialer before the upgrade so it can log through it. A map entry that is not a
*Dialergets a 400 instead of an upgraded connection closed at once. Only*Dialervalues are stored, so no caller reaches that path.Closes shellhub-io/team#346
Evidence
Before: a GET without upgrade headers to
/ssh/connection,/agent/connectionor/ssh/revdial:The server logs
http: superfluous response.WriteHeader callinstead of the cause.After: new cases in
TestHandleConnectionV1StatusCodes,TestHandleConnectionV2StatusCodesandTestConnHandlerAnswersANonUpgradePickupWithOnlyTheUpgradersResponseexpect status 400 and bodyBad Request\n. They fail when the second write is restored and pass with this change. The fullservermodule test suite passes.Merge Danger
Door: two-way
A real agent sends a valid upgrade request, so its handshake does not change. No migration or wire format changes.
Blast Radius: tunnels
Only failed upgrades on the agent connection and revdial pickup paths behave differently: no second write, and a Warn log line. Any client that sends a plain GET to those paths now adds a Warn line to the logs.