{"record":{"id":"6f29d64eb54ce590","repo":"hashicorp/terraform","slug":"no-state-data-received-from-terraform-no-state-da","errorCode":null,"errorMessage":"No state data received from Terraform: No state data was received from Terraform. This is a bug and should be reported.","messagePattern":"No state data received from Terraform: No state data was received from Terraform\\. This is a bug and should be reported\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/grpcwrap/provider6.go","lineNumber":1107,"sourceCode":"\n\t\tn, err := state.Write(chunk.Bytes)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error writing state: %w\", err)\n\t\t}\n\t\ttotalReceivedBytes += n\n\t}\n\n\tif grpcErr != nil {\n\t\treturn grpcErr\n\t}\n\n\tif int64(totalReceivedBytes) != expectedTotalLength {\n\t\treturn fmt.Errorf(\"expected to receive state in %d bytes, actually received %d bytes\", expectedTotalLength, totalReceivedBytes)\n\t}\n\n\tif totalReceivedBytes == 0 {\n\t\t// Even an empty state file has content; no bytes is not valid\n\t\treturn errors.New(\"No state data received from Terraform: No state data was received from Terraform. This is a bug and should be reported.\")\n\t}\n\n\tresp := p.provider.WriteStateBytes(providers.WriteStateBytesRequest{\n\t\tStateId:  stateId,\n\t\tTypeName: typeName,\n\t\tBytes:    state.Bytes(),\n\t})\n\n\terr := srv.SendAndClose(&proto6.WriteStateBytes_Response{\n\t\tDiagnostics: convert.AppendProtoDiag([]*proto6.Diagnostic{}, resp.Diagnostics),\n\t})\n\n\treturn err\n}\n\nfunc (p *provider6) LockState(ctx context.Context, req *tfplugin6.LockState_Request) (*tfplugin6.LockState_Response, error) {\n\tlockResp := p.provider.LockState(providers.LockStateRequest{\n\t\tTypeName:  req.TypeName,","sourceCodeStart":1089,"sourceCodeEnd":1125,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/grpcwrap/provider6.go#L1089-L1125","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Provider-side guard: refuse to close with zero bytes received.\nif totalReceivedBytes == 0 {\n    return errors.New(\"received zero state bytes from client; this is a Terraform core bug\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := srv.WriteStateBytes(...); err != nil {\n    if strings.Contains(err.Error(), \"No state data received from Terraform\") {\n        // report and bisect Terraform core vs provider versions\n        log.Fatal(\"streaming-state protocol produced zero bytes; file a Terraform bug\")\n    }\n    return err\n}","preventionTips":["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."],"tags":["provider","grpc","state","streaming-state","internal-bug","protocol6"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}