{"record":{"id":"b5b72a1df25d99fa","repo":"k3s-io/k3s","slug":"failed-to-run-tailscale-debug-prefs-v","errorCode":null,"errorMessage":"failed to run tailscale debug prefs: %v","messagePattern":"failed to run tailscale debug prefs: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/vpn/vpn.go","lineNumber":185,"sourceCode":"\n\tvar tailscaleOutput TailscaleOutput\n\terr = json.Unmarshal([]byte(output), &tailscaleOutput)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to unmarshal tailscale output: %v\", err)\n\t}\n\n\t// Errors are ignored because the interface might not have ipv4 or ipv6 addresses (that's the only possible error)\n\tipv4Address, _ := util.GetFirst4String(tailscaleOutput.TailscaleIPs)\n\tipv6Address, _ := util.GetFirst6String(tailscaleOutput.TailscaleIPs)\n\n\treturn &Info{BackendState: tailscaleOutput.BackendState, IPv4Address: net.ParseIP(ipv4Address), IPv6Address: net.ParseIP(ipv6Address), NodeID: \"\", ProviderName: \"tailscale\", Interface: tailscaleIf}, nil\n}\n\n// get Tailscale advertised route list\nfunc GetAdvertisedRoutes() ([]netip.Prefix, error) {\n\toutput, err := util.ExecCommand(\"tailscale\", []string{\"debug\", \"prefs\"})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run tailscale debug prefs: %v\", err)\n\t}\n\n\tlogrus.Debugf(\"Output from tailscale debug prefs: %v\", output)\n\n\tvar tailscaleOutput TailscalePrefsOutput\n\terr = json.Unmarshal([]byte(output), &tailscaleOutput)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to unmarshal tailscale output: %v\", err)\n\t}\n\n\treturn tailscaleOutput.AdvertiseRoutes, nil\n}\n\n// processCLIArgs separates the extraArgs part from the command.\n// Note that tailscale flags of type list are comma separated and don't accept spaces, thus we can use strings.Fields to separate flags\nfunc processCLIArgs(command string) (string, []string) {\n\tsubCommands := strings.Split(command, \",extraArgs=\")\n\tif len(subCommands) > 1 {","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/k3s-io/k3s/blob/6ba341e396edc16b8dcae978a7c5e3ac7ee5606e/pkg/vpn/vpn.go#L167-L203","documentation":"GetAdvertisedRoutes runs `tailscale debug prefs` via util.ExecCommand and wraps an exec failure, before unmarshalling AdvertiseRoutes from the prefs JSON. The `debug` subcommands are a less stable CLI surface than the public commands, so failures often track CLI version changes or an absent/broken daemon, mirroring the `status --json` case.","triggerScenarios":"The tailscale CLI is missing, too old to have `debug prefs`, or exits non-zero because tailscaled is not running or is in a broken state.","commonSituations":"Version drift between the node's tailscale CLI and what the code expects (debug subcommands change between releases); airgapped hosts with old CLIs; daemon stopped or not yet logged in.","solutions":["Verify manually: tailscale debug prefs | jq .AdvertiseRoutes","Upgrade the tailscale CLI to a version that supports `debug prefs` and restart tailscaled","Ensure tailscaled is running and the node is operational before querying advertised routes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"tailscale\"); err != nil {\n\treturn fmt.Errorf(\"tailscale CLI not available\")\n}\n// confirm the debug subcommand exists in this CLI version\nif err := exec.Command(\"tailscale\", \"debug\", \"prefs\", \"--help\").Run(); err != nil {\n\treturn fmt.Errorf(\"installed tailscale does not support 'debug prefs': %w\", err)\n}","typeGuard":null,"tryCatchPattern":"routes, err := vpn.GetAdvertisedRoutes()\nif err != nil {\n\tif strings.Contains(err.Error(), \"failed to run tailscale debug prefs\") {\n\t\t// usually missing/old CLI or stopped daemon: check tailscale version and tailscaled\n\t}\n\treturn nil, err\n}","preventionTips":["Do not rely on `tailscale debug` subcommands across versions - verify after upgrades","Keep the tailscale CLI new enough to support `debug prefs` on all VPN nodes","Check tailscaled health before querying advertised routes"],"tags":["go","vpn","tailscale","exec","routes"],"backgroundTag":null,"analyzedSha":"6ba341e396edc16b8dcae978a7c5e3ac7ee5606e","analyzedAt":"2026-08-15T16:27:54.286Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}