{"record":{"id":"53bd16c47828c113","repo":"juanfont/headscale","slug":"s-reading-confirm-response-w","errorCode":null,"errorMessage":"%s reading confirm response: %w","messagePattern":"(.+?) reading confirm response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"integration/scenario.go","lineNumber":1327,"sourceCode":"\n\tctx := context.Background()\n\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, confirmURL.String(), strings.NewReader(formData.Encode()))\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"%s creating confirm request: %w\", hostname, err)\n\t}\n\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\n\tconfirmResp, err := hc.Do(req)\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"%s sending confirm request: %w\", hostname, err)\n\t}\n\tdefer confirmResp.Body.Close()\n\n\tconfirmBytes, err := io.ReadAll(confirmResp.Body)\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"%s reading confirm response: %w\", hostname, err)\n\t}\n\n\tif confirmResp.StatusCode != http.StatusOK {\n\t\treturn string(confirmBytes), nil, fmt.Errorf( //nolint:err113\n\t\t\t\"%s confirm returned status %d: %s\",\n\t\t\thostname, confirmResp.StatusCode, string(confirmBytes),\n\t\t)\n\t}\n\n\treturn string(confirmBytes), nil, nil\n}\n\nvar errParseAuthPage = errors.New(\"parsing auth page\")\n\nfunc (s *Scenario) runHeadscaleRegister(userStr string, body string) error {\n\t// see api.go HTML template\n\tcodeSep := strings.Split(body, \"</code>\")\n\tif len(codeSep) != 2 {","sourceCodeStart":1309,"sourceCodeEnd":1345,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/integration/scenario.go#L1309-L1345","documentation":"`io.ReadAll(confirmResp.Body)` failed while draining the confirm POST response. The request succeeded at the transport level but the body stream broke mid-read — connection reset, content-length mismatch, or the container died while streaming.","triggerScenarios":"The headscale server closes the connection partway through the response body: container OOM-killed or restarted mid-response, proxy in front of headscale truncates, or keep-alive race at test teardown.","commonSituations":"Test tears down containers while an in-flight response is being read; headscale panics during confirm handling; Docker network removed mid-test.","solutions":["Check headscale container logs for a panic or OOM kill at the timestamp of the failure.","Ensure the scenario does not tear down the network/containers before registration completes.","Retry the registration flow; mid-body resets in containerized tests are frequently flakes."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not tear down containers until all in-flight requests complete (sync via WaitGroup).","Watch headscale logs for panics aligned with the failure time.","Treat one-off mid-body resets as flakes; rerun before debugging."],"tags":["http","network","integration"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}