juanfont/headscale · error

deleting preauthkey: %w

Error message

deleting preauthkey: %w

What it means

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.

Source

Thrown at cmd/headscale/cli/preauthkeys.go:193

}

var deletePreAuthKeyCmd = &cobra.Command{
	Use:     cmdDelete,
	Short:   "Delete a preauthkey",
	Aliases: []string{aliasDel, "rm", "d"},
	RunE: clientRunE(func(ctx context.Context, client *clientv1.ClientWithResponses, cmd *cobra.Command, args []string) error {
		id, err := preAuthKeyID(cmd)
		if err != nil {
			return err
		}

		idStr := strconv.FormatUint(id, util.Base10)

		resp, err := client.DeletePreAuthKeyWithResponse(ctx, &clientv1.DeletePreAuthKeyParams{
			Id: &idStr,
		})
		if err != nil {
			return fmt.Errorf("deleting preauthkey: %w", err)
		}

		if resp.StatusCode() != http.StatusOK {
			return apiError(resp.StatusCode(), resp.ApplicationproblemJSONDefault)
		}

		return printOutput(cmd, resp.JSON200, "Key deleted")
	}),
}

View on GitHub (pinned to 565fd254d0)

Solutions

  1. Verify server reachability, then retry.
  2. Confirm the delete actually did not happen (`preauthkeys list`) before re-running — a transport failure usually means no side effect, but confirm.
  3. Check CLI server address and API key.
  4. If a 404/500 shows via apiError instead, the id is wrong or the key is already deleted.
Defensive patterns

Strategy: retry

Try / catch

resp, err := client.DeletePreAuthKeyWithResponse(ctx, params)
if err != nil && isTransportError(err) {
    // confirm with `preauthkeys list` that delete did not land, then retry once
}

Prevention

When it happens

Trigger: headscale unreachable, connection refused/reset, TLS/DNS failure while issuing the DELETE.

Common situations: Server restarted mid-command; admin CLI on an unreachable network; proxy timeout on DELETE verbs.

Related errors


AI-assisted analysis of juanfont/headscale@565fd254d0 (2026-08-15). Data as JSON: /api/errors/3938bb64ffa8635d. Report an issue: GitHub.