hashicorp/terraform · critical

No state data received from Terraform: No state data was rec

Error message

No state data received from Terraform: No state data was received from Terraform. This is a bug and should be reported.

What it means

Thrown in the plugin protocol v6 WriteStateBytes streaming handler (grpcwrap.provider6). After draining the gRPC client stream, totalReceivedBytes is 0; the code asserts that even an empty state file has bytes, so zero bytes indicates the provider sent nothing. The message explicitly says this is a bug to report.

Source

Thrown at internal/grpcwrap/provider6.go:1107

		n, err := state.Write(chunk.Bytes)
		if err != nil {
			return fmt.Errorf("error writing state: %w", err)
		}
		totalReceivedBytes += n
	}

	if grpcErr != nil {
		return grpcErr
	}

	if int64(totalReceivedBytes) != expectedTotalLength {
		return fmt.Errorf("expected to receive state in %d bytes, actually received %d bytes", expectedTotalLength, totalReceivedBytes)
	}

	if totalReceivedBytes == 0 {
		// Even an empty state file has content; no bytes is not valid
		return errors.New("No state data received from Terraform: No state data was received from Terraform. This is a bug and should be reported.")
	}

	resp := p.provider.WriteStateBytes(providers.WriteStateBytesRequest{
		StateId:  stateId,
		TypeName: typeName,
		Bytes:    state.Bytes(),
	})

	err := srv.SendAndClose(&proto6.WriteStateBytes_Response{
		Diagnostics: convert.AppendProtoDiag([]*proto6.Diagnostic{}, resp.Diagnostics),
	})

	return err
}

func (p *provider6) LockState(ctx context.Context, req *tfplugin6.LockState_Request) (*tfplugin6.LockState_Response, error) {
	lockResp := p.provider.LockState(providers.LockStateRequest{
		TypeName:  req.TypeName,

View on GitHub (pinned to c9def3e214)

Solutions

  1. Upgrade the provider to the latest release (likely an already-fixed bug).
  2. Upgrade Terraform/OpenTofu to match the provider's expected protocol version.
  3. Reproduce with the smallest config and capture provider debug logs; report the issue to the provider maintainer with the trace.
  4. Temporarily pin the provider to a known-good older version via required_providers.

Example fix

# pin the provider to a known-good version while the bug is fixed upstream
terraform {
  required_providers {
    example = { source = "acme/example", version = "= 1.2.3" }
  }
}
# then: terraform init -upgrade=false
Defensive patterns

Strategy: validation

Validate before calling

# in config, assert provider/terraform version compatibility before runs that write state
check "versions" {
  assert {
    condition     = can(regex("5\\.", data.tfe_provider.this.version))
    error_message = "provider version incompatible with WriteStateBytes; upgrade"
  }
}

Try / catch

# isolate the failing resource and pin the provider while reporting the bug
terraform { required_providers { x = { source = "acme/x", version = "=1.2.3" } } }

Prevention

When it happens

Trigger: A provider plugin's WriteStateBytes implementation closes the response stream without ever sending a chunk, or sends chunks whose Bytes total zero, during a plan/apply that exercises state writes.

Common situations: Provider crash or panic before streaming state; a provider stub/prototype that returns early; protocol-version incompatibility between Terraform and the provider; resource type not yet implemented in the provider.

Related errors


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