{"record":{"id":"1cb595c83964c598","repo":"hashicorp/nomad","slug":"failed-to-read-respose-w","errorCode":null,"errorMessage":"failed to read respose: %w","messagePattern":"failed to read respose: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"client/fingerprint/env_aws.go","lineNumber":289,"sourceCode":"\n\timdsClient := imds.NewFromConfig(cfg, func(o *imds.Options) {\n\t\t// endpoint should only be overridden for testing\n\t\tif f.endpoint != \"\" {\n\t\t\to.Endpoint = f.endpoint\n\t\t}\n\t})\n\treturn imdsClient, nil\n}\n\nfunc awsProbe(ctx context.Context, client *imds.Client) error {\n\tresp, err := client.GetMetadata(ctx, &imds.GetMetadataInput{Path: \"ami-id\"})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to query AWS metadata: %w\", err)\n\t}\n\n\ts, err := readMetadataResponse(resp)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to read respose: %w\", err)\n\t}\n\n\tif s == \"\" {\n\t\treturn errors.New(\"empty response from AWS metadata\")\n\t}\n\n\treturn nil\n}\n\n// readImdsResponse reads and formats the IMDS response\n// and most importantly, closes the io.ReadCloser\nfunc readMetadataResponse(resp *imds.GetMetadataOutput) (string, error) {\n\tdefer resp.Content.Close()\n\n\tb, err := io.ReadAll(resp.Content)\n\tif err != nil {\n\t\treturn \"\", err\n\t}","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/fingerprint/env_aws.go#L271-L307","documentation":"After a successful GetMetadata call, awsProbe reads the response body via readMetadataResponse. If reading/closing the body or decoding the bytes fails, this wrapped error is returned. (Note the typo 'respose' exists in the source message.)","triggerScenarios":"IMDS returned a response whose body could not be read — connection reset mid-response, truncated body, or an error surfaced by the SDK's response streaming.","commonSituations":"Flaky metadata service under load; network interruption between token acquisition and body read; proxy/NAT interference on link-local traffic.","solutions":["Retry the fingerprint by restarting the Nomad agent","Check host networking for interference with 169.254.169.254 traffic","Verify IMDS service health (instance metadata unavailable errors in dmesg/syslog)","Upgrade the aws-sdk-go-v2 imds client / Nomad version if the bug persists"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"s, err := readMetadataResponse(resp)\nif err != nil {\n    // transient body-read failure: retry once before failing\n    resp2, rerr := client.GetMetadata(ctx, &imds.GetMetadataInput{Path: \"ami-id\"})\n    if rerr == nil { s, err = readMetadataResponse(resp2) }\n    if err != nil { return fmt.Errorf(\"failed to read respose: %w\", err) }\n}","preventionTips":["Add one retry on body-read errors","Check link-local MTU/traffic shaping if truncation recurs","Keep the aws-sdk-go-v2 imds module updated"],"tags":["aws","imds","io"],"backgroundTag":"metadata-response-read-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}