{"record":{"id":"edbfabc627df6176","repo":"juanfont/headscale","slug":"writing-tls-key-to-container-w","errorCode":null,"errorMessage":"writing TLS key to container: %w","messagePattern":"writing TLS key to container: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"integration/dsic/dsic.go","lineNumber":282,"sourceCode":"\n\tfor i, cert := range dsic.caCerts {\n\t\terr = dsic.WriteFile(fmt.Sprintf(\"%s/user-%d.crt\", caCertRoot, i), cert)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"writing TLS certificate to container: %w\", err)\n\t\t}\n\t}\n\n\tif len(dsic.tlsCert) != 0 {\n\t\terr = dsic.WriteFile(fmt.Sprintf(\"%s/%s.crt\", DERPerCertRoot, dsic.hostname), dsic.tlsCert)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"writing TLS certificate to container: %w\", err)\n\t\t}\n\t}\n\n\tif len(dsic.tlsKey) != 0 {\n\t\terr = dsic.WriteFile(fmt.Sprintf(\"%s/%s.key\", DERPerCertRoot, dsic.hostname), dsic.tlsKey)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"writing TLS key to container: %w\", err)\n\t\t}\n\t}\n\n\treturn dsic, nil\n}\n\n// Shutdown stops and cleans up the DERPer container.\nfunc (t *DERPServerInContainer) Shutdown() error {\n\terr := t.SaveLog(\"/tmp/control\")\n\tif err != nil {\n\t\tlog.Printf(\n\t\t\t\"saving log from %s: %s\",\n\t\t\tt.hostname,\n\t\t\tfmt.Errorf(\"saving log: %w\", err),\n\t\t)\n\t}\n\n\treturn t.pool.Purge(t.container)","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/integration/dsic/dsic.go#L264-L300","documentation":"Returned by the DERP integration-test helper when writing the DERPer's TLS private key (<hostname>.key under DERPerCertRoot) into the container fails. Same mechanism as the certificate writes: a container-exec file write that returned an error.","triggerScenarios":"The final WriteFile call for the key material fails — container exited, key path not writable, or Docker exec error. Occurs only when tlsKey is non-empty (TLS-enabled DERPer test).","commonSituations":"DERPer container restarts mid-setup; image runs as a user without write access to the cert root; interrupted Docker daemon during heavy parallel integration runs.","solutions":["Re-run the test — transient exec failures during container provisioning are the most common cause","Check container logs and confirm the DERPer stayed alive through the whole setup phase","Verify image permissions for the DERPer certificate directory if the failure is persistent"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat first-run DERP setup failures as candidates for a single retry after pruning","Watch for container restarts (docker events) while tests provision DERPer"],"tags":["integration-test","docker","tls","derp"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}