{"record":{"id":"9a9dc84b1693508c","repo":"juanfont/headscale","slug":"creating-or-getting-network-w","errorCode":null,"errorMessage":"creating or getting network: %w","messagePattern":"creating or getting network: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"integration/scenario.go","lineNumber":293,"sourceCode":"\t\t}\n\n\t\terr = s.runMockOIDC(ttl, spec.OIDCUsers)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn s, nil\n}\n\nfunc (s *Scenario) AddNetwork(name string) (*dockertest.Network, error) {\n\treturn s.AddNetworkWithSubnet(name, \"\")\n}\n\nfunc (s *Scenario) AddNetworkWithSubnet(name, subnet string) (*dockertest.Network, error) {\n\tnetwork, err := dockertestutil.GetFirstOrCreateNetworkWithSubnet(s.pool, name, subnet)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"creating or getting network: %w\", err)\n\t}\n\n\t// We run the test suite in a docker container that calls a couple of endpoints for\n\t// readiness checks, this ensures that we can run the tests with individual networks\n\t// and have the client reach the different containers.\n\t// The container name includes the run ID to support multiple concurrent test runs.\n\ttestSuiteName := \"headscale-test-suite\"\n\tif runID := dockertestutil.GetIntegrationRunID(); runID != \"\" {\n\t\ttestSuiteName = \"headscale-test-suite-\" + runID\n\t}\n\n\terr = dockertestutil.AddContainerToNetwork(s.pool, network, testSuiteName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"adding test suite container to network: %w\", err)\n\t}\n\n\tmak.Set(&s.networks, name, network)\n","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/integration/scenario.go#L275-L311","documentation":"Returned by Scenario.AddNetwork/AddNetworkWithSubnet when dockertestutil.GetFirstOrCreateNetworkWithSubnet fails to list existing Docker networks or to create the requested network. It wraps Docker daemon errors from network creation/lookup.","triggerScenarios":"Calling s.AddNetwork(name) or s.AddNetworkWithSubnet(name, subnet) when the Docker daemon is unreachable, the subnet string is invalid/overlaps an existing network, or network creation hits a daemon limit.","commonSituations":"Invalid subnet passed to AddNetworkWithSubnet (not CIDR format, or colliding with another test network's range); too many leftover networks from earlier runs exhausting Docker's address pool; Docker socket permission problems.","solutions":["Run `docker network ls` and prune leftover headscale test networks, or run `go run ./cmd/hi cleanup`","Verify the subnet argument is a valid CIDR (e.g. 172.10.0.0/24) and does not overlap existing networks","Confirm the Docker daemon is running and the user has access to /var/run/docker.sock","Check whether another concurrent integration run holds conflicting networks (run IDs should isolate them)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"net, err := scenario.AddNetworkWithSubnet(name, subnet)\nif err != nil {\n    t.Fatalf(\"network setup failed: %v\", err) // environment error; abort the test","preventionTips":["Validate subnet strings as CIDR before passing them","Prune leftover test networks before suites (`hi cleanup`)","Use unique network names per test to avoid collisions"],"tags":["docker","network","integration-test"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}