hashicorp/terraform · critical
No state data received from Terraform: No state data was…
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
Returned by the proto6 gRPC provider wrapper (`grpcwrap/provider6.go`) during the streamed `WriteStateBytes` handling: after the streaming loop completes with no transport error, the total bytes received is zero, which is invalid because even an empty state serializes to non-zero bytes. The message explicitly says this is a Terraform-internal bug to be reported.
Solutions
- Report the bug with the Terraform and provider versions and a reproduction (the message says so explicitly).
- Try a different (stable) version of the provider, or of Terraform core, to bisect the regression.
- If you maintain the provider, ensure your `WriteStateBytes` reads all chunks and accumulates non-empty bytes before responding.
Defensive patterns
Strategy: try-catch
Validate before calling
// Provider-side guard: refuse to close with zero bytes received.
if totalReceivedBytes == 0 {
return errors.New("received zero state bytes from client; this is a Terraform core bug")
} Try / catch
if _, err := srv.WriteStateBytes(...); err != nil {
if strings.Contains(err.Error(), "No state data received from Terraform") {
// report and bisect Terraform core vs provider versions
log.Fatal("streaming-state protocol produced zero bytes; file a Terraform bug")
}
return err
} Prevention
- Pin stable Terraform core + provider versions together; avoid alphas for the streaming-state RPC.
- If you maintain a provider, fully drain and validate the state byte stream before responding.
- Capture core/provider versions in CI logs to make this reported bug reproducible.
When it happens
Trigger: The provider's `WriteStateBytes` gRPC handler receives a `SendAndClose` where the accumulated `state.Bytes()` length is 0 — the client (Terraform core) opened the byte stream but sent zero data chunks. This indicates a broken state serialization path in core or a misbehaving custom provider implementation of the streaming state API.
Common situations: Using an experimental/alpha provider that implements the streaming state migration API incorrectly; a Terraform core regression in the state-bytes sender; protocol mismatch between core and provider on the streaming-state RPC.
Related errors
- action schema not found for action
- error when obtaining provider instance during state store…
- error writing state
- expected to receive state in
- Failed to negotiate acceptable chunk size. Expected size >…
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/6f29d64eb54ce590.
Report an issue: GitHub.
Appendix: 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 d32a084675)