Skip to content

fix(deviceshifuhttp): forward upstream status code in GET/POST handler#1491

Open
AruneshDwivedi wants to merge 1 commit into
Edgenesis:mainfrom
AruneshDwivedi:fix/deviceshifuhttp-writeheader
Open

fix(deviceshifuhttp): forward upstream status code in GET/POST handler#1491
AruneshDwivedi wants to merge 1 commit into
Edgenesis:mainfrom
AruneshDwivedi:fix/deviceshifuhttp-writeheader

Conversation

@AruneshDwivedi

Copy link
Copy Markdown

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).

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

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 35.11%. Comparing base (80f41c5) to head (19fadd7).
⚠️ Report is 6 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant