{"record":{"id":"af0bbd15167f7e6e","repo":"juanfont/headscale","slug":"no-docker-context-found","errorCode":null,"errorMessage":"no docker context found","messagePattern":"no docker context found","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/hi/docker.go","lineNumber":31,"sourceCode":"\t\"path/filepath\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/cenkalti/backoff/v5\"\n\t\"github.com/docker/docker/api/types/container\"\n\t\"github.com/docker/docker/api/types/image\"\n\t\"github.com/docker/docker/api/types/mount\"\n\t\"github.com/docker/docker/client\"\n\t\"github.com/docker/docker/pkg/stdcopy\"\n\t\"github.com/juanfont/headscale/integration/dockertestutil\"\n)\n\nconst defaultDirPerm = 0o755\n\nvar (\n\tErrTestFailed              = errors.New(\"test failed\")\n\tErrUnexpectedContainerWait = errors.New(\"unexpected end of container wait\")\n\tErrNoDockerContext         = errors.New(\"no docker context found\")\n\tErrMemoryLimitViolations   = errors.New(\"container(s) exceeded memory limits\")\n)\n\n// runTestContainer executes integration tests in a Docker container.\n//\n//nolint:gocyclo // complex test orchestration function\nfunc runTestContainer(ctx context.Context, config *RunConfig) error {\n\tcli, err := createDockerClient(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating Docker client: %w\", err)\n\t}\n\tdefer cli.Close()\n\n\trunID := dockertestutil.GenerateRunID()\n\tcontainerName := \"headscale-test-suite-\" + runID\n\tlogsDir := filepath.Join(config.LogsDir, runID)\n\n\tif config.Verbose {","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/cmd/hi/docker.go#L13-L49","documentation":"Guard error from doLoginURLWithClient when the caller passes a nil *http.Client. The function needs a real client (with the debug cookie jar) to perform the login GET, so it refuses immediately instead of panicking on hc.Do later.","triggerScenarios":"Calling doLoginURLWithClient (directly or via a helper) with hc == nil — e.g. the caller ignored the error from newLoginHTTPClient and passed the nil result straight through.","commonSituations":"Ignoring the error from newLoginHTTPClient and proceeding with the zero-value client; refactoring that dropped client construction from a call path.","solutions":["Check the error from newLoginHTTPClient before using the client.","Pass the client returned by newLoginHTTPClient(hostname), never a hand-built nil."],"exampleFix":"// before\nhc, _ := newLoginHTTPClient(hostname)\nbody, redir, err := doLoginURLWithClient(hostname, loginURL, hc, true)\n// after\nhc, err := newLoginHTTPClient(hostname)\nif err != nil {\n    return nil, nil, err\n}\nbody, redir, err := doLoginURLWithClient(hostname, loginURL, hc, true)","handlingStrategy":"validation","validationCode":"hc, err := newLoginHTTPClient(hostname)\nif err != nil {\n    return err\n}\nif hc == nil {\n    return fmt.Errorf(\"%s http client unexpectedly nil\", hostname)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never ignore the error from constructors that return (client, error).","Pass only clients built by newLoginHTTPClient into the login helpers."],"tags":["integration","http","nil-guard","api-misuse"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}