{"record":{"id":"26187f5ecb4c4514","repo":"juanfont/headscale","slug":"adding-test-suite-container-to-network-w","errorCode":null,"errorMessage":"adding test suite container to network: %w","messagePattern":"adding test suite container to network: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"integration/scenario.go","lineNumber":307,"sourceCode":"\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\n\treturn network, nil\n}\n\nfunc (s *Scenario) Networks() []*dockertest.Network {\n\tif len(s.networks) == 0 {\n\t\tpanic(\"Scenario.Networks called with empty network list\")\n\t}\n\n\treturn xmaps.Values(s.networks)\n}\n\nfunc (s *Scenario) Network(name string) (*dockertest.Network, error) {\n\tnet, ok := s.networks[s.prefixedNetworkName(name)]\n\tif !ok {","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/integration/scenario.go#L289-L325","documentation":"Returned by Scenario.AddNetworkWithSubnet when dockertestutil.AddContainerToNetwork fails to attach the test-suite container (headscale-test-suite[-runID]) to the newly created network. The suite container must be attached so test-code HTTP readiness checks can reach containers on per-test networks.","triggerScenarios":"Occurs when the headscale-test-suite container does not exist (suite not running under cmd/hi), has been removed mid-run, or the Docker API call to connect it to the network fails.","commonSituations":"Running integration tests with `go test ./integration/...` directly instead of through the hi runner that creates the suite container; a previous run's cleanup removed the suite container while a test was adding a network; concurrent runs with colliding run IDs.","solutions":["Run integration tests via the documented runner: `go run ./cmd/hi run \"TestName\"` which creates the test-suite container","Run `go run ./cmd/hi doctor` to verify the environment is healthy before running tests","If a run was interrupted, clean stale state with `go run ./cmd/hi cleanup` and retry"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := scenario.AddNetwork(name); err != nil {\n    t.Fatalf(\"network setup failed: %v\", err)\n}","preventionTips":["Always launch integration tests through cmd/hi so the test-suite container exists","Run `hi doctor` before a suite","Avoid mixing direct `go test` runs with hi-managed runs on the same Docker daemon"],"tags":["docker","network","integration-test","test-runner"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}