{"record":{"id":"284b474ae0d5228f","repo":"tailscale/tailscale","slug":"creating-token-request-w","errorCode":null,"errorMessage":"creating token request: %w","messagePattern":"creating token request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/cloudinfo/cloudinfo.go","lineNumber":120,"sourceCode":"\t}\n\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reading response body for %q: %w\", path, err)\n\t}\n\n\treturn strings.Split(strings.TrimSpace(string(body)), \"\\n\"), nil\n}\n\n// getAWS returns all public IPv4 and IPv6 addresses present in the AWS instance metadata.\nfunc (ci *CloudInfo) getAWS(ctx context.Context) ([]netip.Addr, error) {\n\tctx, cancel := context.WithTimeout(ctx, maxCloudInfoWait)\n\tdefer cancel()\n\n\t// Get a token so we can query the metadata service.\n\treq, err := http.NewRequestWithContext(ctx, \"PUT\", ci.endpoint+\"/latest/api/token\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"creating token request: %w\", err)\n\t}\n\treq.Header.Set(\"X-Aws-Ec2-Metadata-Token-Ttl-Seconds\", \"10\")\n\n\tresp, err := ci.client.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"making token request to metadata service: %w\", err)\n\t}\n\tbody, err := io.ReadAll(resp.Body)\n\tresp.Body.Close()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reading token response body: %w\", err)\n\t}\n\ttoken := string(body)\n\n\tserver := resp.Header.Get(\"Server\")\n\tif server != \"EC2ws\" {\n\t\treturn nil, fmt.Errorf(\"unexpected server header: %q\", server)\n\t}","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/tailscale/tailscale/blob/6e0912f97994f927632b34ae9e63b53d6516a6ac/util/cloudinfo/cloudinfo.go#L102-L138","documentation":"In getAWS, constructing the PUT request for an IMDSv2 token failed at http.NewRequestWithContext — a URL-parsing failure of ci.endpoint+\"/latest/api/token\", not a network error. Nothing has been sent yet; the endpoint string is effectively invalid.","triggerScenarios":"Thrown at util/cloudinfo/cloudinfo.go:120 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the metadata endpoint configuration to a valid absolute URL","Reject this as a permanent config error; retrying cannot help since no request was made"],"exampleFix":null,"handlingStrategy":"validation","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"}