From 88844670af565909e2fc610d62b08a5025aa934b Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Wed, 25 Feb 2026 10:47:14 -0500 Subject: [PATCH] Fix integration test bug: premature response body close MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed critical bug in TestScanProgress_BatchingWorks integration test where response body was closed before JSON decoding, causing test failure. Bug Location: Line 604 in scanner_integration_test.go example code Problem: scanResp, err := client.Do(scanReq) require.NoError(s.T(), err) scanResp.Body.Close() // ❌ Closed here var scanResponse map[string]interface{} json.NewDecoder(scanResp.Body).Decode(&scanResponse) // ❌ Reads from closed body Fix: scanResp, err := client.Do(scanReq) require.NoError(s.T(), err) var scanResponse map[string]interface{} json.NewDecoder(scanResp.Body).Decode(&scanResponse) scanResp.Body.Close() // ✅ Close AFTER decoding This matches the pattern used in TestScanProgress_TracksStatistics and ensures the response body is available for JSON decoding before being closed. The implementation plan is now fully correct and ready for execution. --- TASKS-backend-progress-tracking.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TASKS-backend-progress-tracking.md b/TASKS-backend-progress-tracking.md index 94839a9..b810b9c 100644 --- a/TASKS-backend-progress-tracking.md +++ b/TASKS-backend-progress-tracking.md @@ -601,10 +601,10 @@ func (s *ScannerIntegrationTestSuite) TestScanProgress_BatchingWorks() { scanResp, err := client.Do(scanReq) require.NoError(s.T(), err) - scanResp.Body.Close() var scanResponse map[string]interface{} json.NewDecoder(scanResp.Body).Decode(&scanResponse) + scanResp.Body.Close() jobID, ok := scanResponse["job_id"].(string) require.True(s.T(), ok, "job_id should be string")