{"record":{"id":"7d228374012f2122","repo":"kubernetes/kops","slug":"building-metadata-token-request-w","errorCode":null,"errorMessage":"building metadata token request: %w","messagePattern":"building metadata token request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/linode/linodemetadata/authenticator.go","lineNumber":78,"sourceCode":"\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to fetch Akamai (Linode) instance id: %w\", err)\n\t}\n\n\treturn LinodeAuthenticationTokenPrefix + instanceID, nil\n}\n\n// GetMetadataValue fetches the given field from the Akamai (Linode) instance metadata service\n// using the standard metadata endpoint and default HTTP client.\nfunc GetMetadataValue(ctx context.Context, key string) (string, error) {\n\treturn getLinodeMetadataValue(ctx, http.DefaultClient, linodeMetadataBaseURL, key)\n}\n\n// getLinodeMetadataValue queries the Akamai (Linode) metadata service for the given key\n// and returns the value as a string.\nfunc getLinodeMetadataValue(ctx context.Context, client *http.Client, metadataBaseURL, key string) (string, error) {\n\ttokenReq, err := http.NewRequestWithContext(ctx, http.MethodPut, metadataBaseURL+\"/v1/token\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"building metadata token request: %w\", err)\n\t}\n\ttokenReq.Header.Set(\"Metadata-Token-Expiry-Seconds\", linodeMetadataTokenTTL)\n\n\ttokenResp, err := client.Do(tokenReq)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"fetching metadata token: %w\", err)\n\t}\n\tdefer tokenResp.Body.Close()\n\n\tif tokenResp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"fetching metadata token: unexpected status code %d\", tokenResp.StatusCode)\n\t}\n\n\ttokenBytes, err := io.ReadAll(tokenResp.Body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"reading metadata token response: %w\", err)\n\t}\n","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/linode/linodemetadata/authenticator.go#L60-L96","documentation":"getLinodeMetadataValue wraps the http.NewRequestWithContext error when constructing the PUT request that obtains a metadata token from the Linode metadata service. It fires only when the request URL/method combination is invalid — essentially a programmer/configuration error in metadataBaseURL, not a runtime condition.","triggerScenarios":"Thrown at upup/pkg/fi/cloudup/linode/linodemetadata/authenticator.go:78 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate the metadataBaseURL passed to getLinodeMetadataValue is a well-formed absolute URL","Ensure the base URL has no invalid characters or scheme typos","Fix at configuration/code level rather than retrying, since the error is deterministic"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}