fix(deviceshifuhttp): forward upstream status code in GET/POST handler#1491
Open
AruneshDwivedi wants to merge 1 commit into
Open
fix(deviceshifuhttp): forward upstream status code in GET/POST handler#1491AruneshDwivedi wants to merge 1 commit into
AruneshDwivedi wants to merge 1 commit into
Conversation
Go's net/http implicitly writes 200 OK when the ResponseWriter is written to without a prior WriteHeader call. The GET/POST instruction handler copied the response body but never called WriteHeader with the upstream status code, so non-2xx responses (e.g. 500 from a failed device probe) were silently translated to 200 OK. Adds w.WriteHeader(resp.StatusCode) before io.Copy, matching the pattern already used by the HTTPCommandline handler in the same file. Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1491 +/- ##
==========================================
+ Coverage 35.09% 35.11% +0.01%
==========================================
Files 54 54
Lines 4029 4030 +1
==========================================
+ Hits 1414 1415 +1
Misses 2461 2461
Partials 154 154 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
The GET/POST instruction handler in deviceshifuhttp.go copied the response body from the upstream device server but never called WriteHeader with the actual status code. Go's net/http implicitly writes 200 OK on the first write to the ResponseWriter, so any non-2xx response (e.g. 500 from a failed device probe) was silently translated to 200 OK. This breaks status-code-based health checks and monitoring.
Adds w.WriteHeader(resp.StatusCode) before io.Copy, matching the pattern already used by the HTTPCommandline handler in the same file (line ~371).