kubernetes/kops · error
building metadata token request: %w
Error message
building metadata token request: %w
What it means
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.
Source
Thrown at upup/pkg/fi/cloudup/linode/linodemetadata/authenticator.go:78
if err != nil {
return "", fmt.Errorf("unable to fetch Akamai (Linode) instance id: %w", err)
}
return LinodeAuthenticationTokenPrefix + instanceID, nil
}
// GetMetadataValue fetches the given field from the Akamai (Linode) instance metadata service
// using the standard metadata endpoint and default HTTP client.
func GetMetadataValue(ctx context.Context, key string) (string, error) {
return getLinodeMetadataValue(ctx, http.DefaultClient, linodeMetadataBaseURL, key)
}
// getLinodeMetadataValue queries the Akamai (Linode) metadata service for the given key
// and returns the value as a string.
func getLinodeMetadataValue(ctx context.Context, client *http.Client, metadataBaseURL, key string) (string, error) {
tokenReq, err := http.NewRequestWithContext(ctx, http.MethodPut, metadataBaseURL+"/v1/token", nil)
if err != nil {
return "", fmt.Errorf("building metadata token request: %w", err)
}
tokenReq.Header.Set("Metadata-Token-Expiry-Seconds", linodeMetadataTokenTTL)
tokenResp, err := client.Do(tokenReq)
if err != nil {
return "", fmt.Errorf("fetching metadata token: %w", err)
}
defer tokenResp.Body.Close()
if tokenResp.StatusCode != http.StatusOK {
return "", fmt.Errorf("fetching metadata token: unexpected status code %d", tokenResp.StatusCode)
}
tokenBytes, err := io.ReadAll(tokenResp.Body)
if err != nil {
return "", fmt.Errorf("reading metadata token response: %w", err)
}
View on GitHub (pinned to 4c8573c808)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at upup/pkg/fi/cloudup/linode/linodemetadata/authenticator.go:78 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/7d228374012f2122.
Report an issue: GitHub.