{"record":{"id":"e6b047df2da154d0","repo":"juanfont/headscale","slug":"expiring-preauthkey-w","errorCode":null,"errorMessage":"expiring preauthkey: %w","messagePattern":"expiring preauthkey: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/headscale/cli/preauthkeys.go","lineNumber":166,"sourceCode":"}\n\nvar expirePreAuthKeyCmd = &cobra.Command{\n\tUse:     cmdExpire,\n\tShort:   \"Expire a preauthkey\",\n\tAliases: []string{\"revoke\", aliasExp, \"e\"},\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.ExpirePreAuthKeyWithResponse(ctx, clientv1.ExpirePreAuthKeyJSONRequestBody{\n\t\t\tId: &idStr,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"expiring 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 expired\")\n\t}),\n}\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","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/cmd/headscale/cli/preauthkeys.go#L148-L184","documentation":"Thrown by `headscale preauthkeys expire` when client.ExpirePreAuthKeyWithResponse() fails at the transport level. The --id was read and formatted successfully; the HTTP call to the running server never completed. Non-200 responses go through apiError instead.","triggerScenarios":"Server unreachable/down, TLS or DNS failure, connection reset while sending the expire request.","commonSituations":"Expiring a key during a server restart; network partition between admin box and server; stale server_url.","solutions":["Confirm the server is up and reachable.","Retry after connectivity is restored; expiry is idempotent.","Verify CLI configuration (address, API key).","If a 404 appears instead (via apiError), re-check the id with `preauthkeys list`."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"resp, err := client.ExpirePreAuthKeyWithResponse(ctx, body)\nif err != nil && isTransportError(err) {\n    // expiry is idempotent: retry with backoff, then verify via preauthkeys list\n}","preventionTips":["Confirm server reachability before revocation runs in incident automation.","Verify expiry state after the operation (`preauthkeys list` shows expiration).","Prefer expiring over deleting when audit trail matters — expired keys remain inspectable."],"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"}