{"record":{"id":"2e7257505a9258fa","repo":"juanfont/headscale","slug":"finding-headscale-w","errorCode":null,"errorMessage":"finding headscale: %w","messagePattern":"finding headscale: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"integration/scenario.go","lineNumber":1371,"sourceCode":"\n\tkey := keySep[1]\n\tkey = strings.SplitN(key, \" \", 2)[0]\n\tlog.Printf(\"registering node %s\", key)\n\n\tif headscale, err := s.Headscale(); err == nil { //nolint:noinlineerr\n\t\t_, err = headscale.Execute(\n\t\t\t[]string{\"headscale\", \"auth\", \"register\", \"--user\", userStr, \"--auth-id\", key},\n\t\t)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"registering node: %s\", err)\n\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t}\n\n\treturn fmt.Errorf(\"finding headscale: %w\", errNoHeadscaleAvailable)\n}\n\ntype LoggingRoundTripper struct {\n\tHostname string\n}\n\nfunc (t LoggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {\n\tnoTls := &http.Transport{\n\t\tTLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // nolint\n\t}\n\n\tresp, err := noTls.RoundTrip(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t//nolint:gosec // G706: integration-only log of trusted scenario state\n\tlog.Printf(`","sourceCodeStart":1353,"sourceCodeEnd":1389,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/integration/scenario.go#L1353-L1389","documentation":"The Scenario has no headscale container available to service the operation; the loop over candidate headscale instances found none, so the helper returns `fmt.Errorf(\"finding headscale: %w\", errNoHeadscaleAvailable)`. It means `s.headscale` (or the pool of instances) was never populated or has been torn down.","triggerScenarios":"Calling a Scenario method that needs a control server (e.g. runHeadscaleRegister's CLI path) before `Scenario.CreateHeadscale`/`Start` succeeded, or after shutdown removed the container.","commonSituations":"Test helper ordering mistake — registering a node before the headscale container is started; a prior startup failed silently and the test continued; teardown ran early.","solutions":["Ensure `CreateHeadscale`/`Start` is called and its error checked before any register/status helper.","If startup failed, look at that earlier error — this one is only a downstream symptom.","Guard test setup with `require.NoError` on headscale creation so failures abort before reaching here."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Fail fast before using the scenario.\nif s.Headscale() == nil { // or equivalent accessor\n    t.Fatal(\"no headscale available; call CreateHeadscale first\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["require.NoError on headscale creation before any dependent call.","Never continue a test after a failed Start/CreateHeadscale.","Order test helpers: network -> headscale -> users -> clients."],"tags":["integration","lifecycle","headscale"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}