{"record":{"id":"2cd89724720bdc29","repo":"tailscale/tailscale","slug":"gcp-metadata-returned-empty-token","errorCode":null,"errorMessage":"gcp metadata returned empty token","messagePattern":"gcp metadata returned empty token","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wif/wif.go","lineNumber":244,"sourceCode":"\tclient := httpClient()\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"call gcp metadata identity endpoint: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode/100 != 2 {\n\t\tb, _ := io.ReadAll(io.LimitReader(resp.Body, 2048))\n\t\treturn \"\", fmt.Errorf(\"gcp metadata identity endpoint returned %s: %s\", resp.Status, strings.TrimSpace(string(b)))\n\t}\n\n\tb, err := io.ReadAll(io.LimitReader(resp.Body, 1024*1024))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"read gcp id token: %w\", err)\n\t}\n\tjwt := strings.TrimSpace(string(b))\n\tif jwt == \"\" {\n\t\treturn \"\", fmt.Errorf(\"gcp metadata returned empty token\")\n\t}\n\n\treturn jwt, nil\n}\n","sourceCodeStart":226,"sourceCodeEnd":249,"githubUrl":"https://github.com/tailscale/tailscale/blob/6e0912f97994f927632b34ae9e63b53d6516a6ac/wif/wif.go#L226-L249","documentation":"acquireGCPMetadataIDToken read the identity endpoint body successfully but it was empty after trimming. The metadata server returned no JWT, usually because the instance has no service account or the audience is invalid.","triggerScenarios":"Thrown at wif/wif.go:244 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the VM's service account has an identity configured","Check the audience and format parameters, then retry"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6e0912f97994f927632b34ae9e63b53d6516a6ac","analyzedAt":"2026-08-18T08:17:25.280Z","contentChangedAt":"2026-08-18T08:17:25.280Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}