hashicorp/terraform · error

could not read state version outputs: %w

Error message

could not read state version outputs: %w

What it means

GetRootOutputValues' retry loop failed with an error that is neither deadline-exceeded nor cancellation. Typically StateVersionOutputs.ReadCurrent returned a non-retryable failure (auth, 404, etc.) wrapped in NonRetryableError.

Source

Thrown at internal/cloud/state.go:572

		so, err = s.tfeClient.StateVersionOutputs.ReadCurrent(ctx, s.workspace.ID)

		if err != nil {
			if strings.Contains(err.Error(), "service unavailable") {
				return err
			}
			return NonRetryableError{err}
		}
		return nil
	})

	if err != nil {
		switch err {
		case context.DeadlineExceeded:
			return nil, fmt.Errorf("current outputs were not ready to be read within the deadline. Please try again")
		case context.Canceled:
			return nil, fmt.Errorf("canceled reading current outputs")
		}
		return nil, fmt.Errorf("could not read state version outputs: %w", err)
	}

	result := make(map[string]*states.OutputValue)

	for _, output := range so.Items {
		if output.DetailedType == nil {
			// If there is no detailed type information available, this state was probably created
			// with a version of terraform < 1.3.0. In this case, we'll eject completely from this
			// function and fall back to the old behavior of reading the entire state file, which
			// requires a higher level of authorization.
			log.Printf("[DEBUG] falling back to reading full state")

			if err := s.RefreshState(); err != nil {
				return nil, fmt.Errorf("failed to load state: %w", err)
			}

			state := s.State()
			if state == nil {

View on GitHub (pinned to c9def3e214)

Solutions

  1. Verify the token can read workspace outputs.
  2. Confirm the workspace and organization are correct and still exist.
  3. Re-authenticate with terraform login.
  4. Retry if the underlying error looked transient.

Example fix

# before: token without output-read scope -> could not read state version outputs
# after: grant output-read / re-login, then retry
terraform login app.terraform.io
terraform output
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight: confirm outputs endpoint is readable with current token
if _, err := client.StateVersionOutputs.ReadCurrent(ctx, workspace.ID); err != nil {
    return fmt.Errorf("cannot read state version outputs: %w", err)
}

Try / catch

outs, err := state.GetRootOutputValues(ctx)
if err != nil && !isTransientHTTP(err) {
    // non-retryable: fix token scope / workspace, then re-run
}

Prevention

When it happens

Trigger: The token lacks permission to read outputs, the workspace/output is not found, or a non-503 API error occurs during ReadCurrent.

Common situations: Expired or under-scoped token, workspace deleted concurrently, or organization misconfiguration.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/5bffe2461b34c2e1. Report an issue: GitHub.