hashicorp/nomad · warning

failed to read respose: %w

Error message

failed to read respose: %w

What it means

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.)

Source

Thrown at client/fingerprint/env_aws.go:289

	imdsClient := imds.NewFromConfig(cfg, func(o *imds.Options) {
		// endpoint should only be overridden for testing
		if f.endpoint != "" {
			o.Endpoint = f.endpoint
		}
	})
	return imdsClient, nil
}

func awsProbe(ctx context.Context, client *imds.Client) error {
	resp, err := client.GetMetadata(ctx, &imds.GetMetadataInput{Path: "ami-id"})
	if err != nil {
		return fmt.Errorf("failed to query AWS metadata: %w", err)
	}

	s, err := readMetadataResponse(resp)
	if err != nil {
		return fmt.Errorf("failed to read respose: %w", err)
	}

	if s == "" {
		return errors.New("empty response from AWS metadata")
	}

	return nil
}

// readImdsResponse reads and formats the IMDS response
// and most importantly, closes the io.ReadCloser
func readMetadataResponse(resp *imds.GetMetadataOutput) (string, error) {
	defer resp.Content.Close()

	b, err := io.ReadAll(resp.Content)
	if err != nil {
		return "", err
	}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Retry the fingerprint by restarting the Nomad agent
  2. Check host networking for interference with 169.254.169.254 traffic
  3. Verify IMDS service health (instance metadata unavailable errors in dmesg/syslog)
  4. Upgrade the aws-sdk-go-v2 imds client / Nomad version if the bug persists
Defensive patterns

Strategy: retry

Try / catch

s, err := readMetadataResponse(resp)
if err != nil {
    // transient body-read failure: retry once before failing
    resp2, rerr := client.GetMetadata(ctx, &imds.GetMetadataInput{Path: "ami-id"})
    if rerr == nil { s, err = readMetadataResponse(resp2) }
    if err != nil { return fmt.Errorf("failed to read respose: %w", err) }
}

Prevention

When it happens

Trigger: 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.

Common situations: Flaky metadata service under load; network interruption between token acquisition and body read; proxy/NAT interference on link-local traffic.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/1cb595c83964c598. Report an issue: GitHub.