{"record":{"id":"7b8a2335d91f6df3","repo":"kubernetes/kops","slug":"fetching-instance-metadata-unexpected-status-code","errorCode":null,"errorMessage":"fetching instance metadata: unexpected status code %d","messagePattern":"fetching instance metadata: unexpected status code (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/linode/linodemetadata/authenticator.go","lineNumber":115,"sourceCode":"\ttoken := strings.TrimSpace(string(tokenBytes))\n\tif token == \"\" {\n\t\treturn \"\", fmt.Errorf(\"metadata token was empty\")\n\t}\n\n\tinstanceReq, err := http.NewRequestWithContext(ctx, http.MethodGet, metadataBaseURL+\"/v1/instance\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"building instance metadata request: %w\", err)\n\t}\n\tinstanceReq.Header.Set(\"Metadata-Token\", token)\n\n\tinstanceResp, err := client.Do(instanceReq)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"fetching instance metadata: %w\", err)\n\t}\n\tdefer instanceResp.Body.Close()\n\n\tif instanceResp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"fetching instance metadata: unexpected status code %d\", instanceResp.StatusCode)\n\t}\n\n\tinstanceBytes, err := io.ReadAll(instanceResp.Body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"reading instance metadata response: %w\", err)\n\t}\n\n\tvalue := parseLinodeMetadataValue(string(instanceBytes), key)\n\tif value == \"\" {\n\t\treturn \"\", fmt.Errorf(\"instance %s from Akamai (Linode) metadata was empty\", key)\n\t}\n\treturn value, nil\n}\n\n// parseLinodeMetadataValue parses the Akamai (Linode) metadata response for the given key\n// and returns the value as a string.\nfunc parseLinodeMetadataValue(metadata string, key string) string {\n\tprefix := key + \":\"","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/linode/linodemetadata/authenticator.go#L97-L133","documentation":"getLinodeMetadataValue rejects the instance metadata response because GET /v1/instance returned a non-200 status. It fires when the metadata token was rejected/expired or the instance metadata service is disabled, so the requested key cannot be read.","triggerScenarios":"Thrown at upup/pkg/fi/cloudup/linode/linodemetadata/authenticator.go:115 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["On 401/403, re-mint the metadata token and retry; the token may have expired","On 404, verify the metadata service is enabled for the instance","Retry with backoff on 429/5xx"],"exampleFix":null,"handlingStrategy":"retry","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-12T07:17:12.445Z"}