{"record":{"id":"5e6d3d84551542bf","repo":"k3s-io/k3s","slug":"failed-to-run-tailscale-status-json-v","errorCode":null,"errorMessage":"failed to run tailscale status --json: %v","messagePattern":"failed to run tailscale status --json: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/vpn/vpn.go","lineNumber":163,"sourceCode":"\t\tif authInfo.JoinKey == \"\" {\n\t\t\treturn errors.New(\"VPN Error. Tailscale requires a JoinKey\")\n\t\t}\n\t\tif authInfo.ControlServerURL != \"\" {\n\t\t\tif _, err := url.Parse(authInfo.ControlServerURL); err != nil {\n\t\t\t\treturn fmt.Errorf(\"VPN Error. Invalid control server URL for Tailscale: %w\", err)\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\n\treturn errors.New(\"Requested VPN: \" + authInfo.Name + \" is not supported. We currently only support tailscale\")\n}\n\n// getTailscaleInfo returns the IPs of the interface\nfunc getTailscaleInfo() (*Info, error) {\n\toutput, err := util.ExecCommand(\"tailscale\", []string{\"status\", \"--json\"})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run tailscale status --json: %v\", err)\n\t}\n\n\tlogrus.Debugf(\"Output from tailscale status --json: %v\", output)\n\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","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/k3s-io/k3s/blob/6ba341e396edc16b8dcae978a7c5e3ac7ee5606e/pkg/vpn/vpn.go#L145-L181","documentation":"getTailscaleInfo shells out to `tailscale status --json` via util.ExecCommand; a failure of that exec (binary not found on PATH, or the command exiting non-zero) is wrapped here. It is called by GetInfo and by StartVPN to decide whether tailscale is already in the Running state.","triggerScenarios":"The tailscale CLI is not installed or not on PATH; tailscaled is not running so `tailscale status` exits non-zero; tailscale is in a broken or logged-out state that makes the command fail.","commonSituations":"Host or container image without the tailscale CLI installed; tailscaled systemd unit not started; agent container lacking the binary while its config requests the VPN; partial upgrades leaving a broken CLI.","solutions":["Check the CLI: command -v tailscale && tailscale version","Check the daemon: systemctl status tailscaled, then start/enable it","Run tailscale status manually to see the real failure and fix it (login state, permissions, socket path)","If the binary must exist inside a container, ensure the image installs it and PATH includes it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"tailscale\"); err != nil {\n\treturn fmt.Errorf(\"tailscale CLI not installed or not on PATH\")\n}\n// optional: confirm the daemon answers before starting\nif out, err := exec.Command(\"tailscale\", \"status\").CombinedOutput(); err != nil {\n\treturn fmt.Errorf(\"tailscale not operational: %v (%s)\", err, out)\n}","typeGuard":null,"tryCatchPattern":"info, err := vpn.GetInfo(vpnAuth)\nif err != nil {\n\tif strings.Contains(err.Error(), \"failed to run tailscale status --json\") {\n\t\t// check: command -v tailscale; systemctl status tailscaled\n\t}\n\treturn nil, err\n}","preventionTips":["Install the tailscale CLI in the image/host before enabling the VPN integration","Ensure tailscaled is enabled and running before the agent starts the VPN","Smoke-test `tailscale status` manually once per host to catch login/state issues","Keep tailscale CLI and daemon versions in sync"],"tags":["go","vpn","tailscale","exec","cli"],"backgroundTag":null,"analyzedSha":"6ba341e396edc16b8dcae978a7c5e3ac7ee5606e","analyzedAt":"2026-08-15T16:27:54.286Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}