{"record":{"id":"3938bb64ffa8635d","repo":"juanfont/headscale","slug":"deleting-preauthkey-w","errorCode":null,"errorMessage":"deleting preauthkey: %w","messagePattern":"deleting preauthkey: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/headscale/cli/preauthkeys.go","lineNumber":193,"sourceCode":"}\n\nvar deletePreAuthKeyCmd = &cobra.Command{\n\tUse:     cmdDelete,\n\tShort:   \"Delete a preauthkey\",\n\tAliases: []string{aliasDel, \"rm\", \"d\"},\n\tRunE: clientRunE(func(ctx context.Context, client *clientv1.ClientWithResponses, cmd *cobra.Command, args []string) error {\n\t\tid, err := preAuthKeyID(cmd)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tidStr := strconv.FormatUint(id, util.Base10)\n\n\t\tresp, err := client.DeletePreAuthKeyWithResponse(ctx, &clientv1.DeletePreAuthKeyParams{\n\t\t\tId: &idStr,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"deleting preauthkey: %w\", err)\n\t\t}\n\n\t\tif resp.StatusCode() != http.StatusOK {\n\t\t\treturn apiError(resp.StatusCode(), resp.ApplicationproblemJSONDefault)\n\t\t}\n\n\t\treturn printOutput(cmd, resp.JSON200, \"Key deleted\")\n\t}),\n}\n","sourceCodeStart":175,"sourceCodeEnd":203,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/cmd/headscale/cli/preauthkeys.go#L175-L203","documentation":"Thrown by `headscale preauthkeys delete` when client.DeletePreAuthKeyWithResponse() fails at the transport level. The --id was parsed and passed as a query parameter; the DELETE request never got a response. HTTP error statuses are surfaced via apiError, not here.","triggerScenarios":"headscale unreachable, connection refused/reset, TLS/DNS failure while issuing the DELETE.","commonSituations":"Server restarted mid-command; admin CLI on an unreachable network; proxy timeout on DELETE verbs.","solutions":["Verify server reachability, then retry.","Confirm the delete actually did not happen (`preauthkeys list`) before re-running — a transport failure usually means no side effect, but confirm.","Check CLI server address and API key.","If a 404/500 shows via apiError instead, the id is wrong or the key is already deleted."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"resp, err := client.DeletePreAuthKeyWithResponse(ctx, params)\nif err != nil && isTransportError(err) {\n    // confirm with `preauthkeys list` that delete did not land, then retry once\n}","preventionTips":["Delete is destructive and unverifiable after success — always confirm via listing after retries.","Script deletes with a pre-check that the id exists (preauthkeys list) to avoid acting on stale ids.","Keep server health checks in cleanup pipelines."],"tags":["network","http","cli","preauthkeys"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}