{"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/c9def3e214014c1188faabfc4a5bde5095139765/internal/grpcwrap/provider6.go#L1089-L1125","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Upgrade the provider to the latest release (likely an already-fixed bug).","Upgrade Terraform/OpenTofu to match the provider's expected protocol version.","Reproduce with the smallest config and capture provider debug logs; report the issue to the provider maintainer with the trace.","Temporarily pin the provider to a known-good older version via required_providers."],"exampleFix":"# pin the provider to a known-good version while the bug is fixed upstream\nterraform {\n  required_providers {\n    example = { source = \"acme/example\", version = \"= 1.2.3\" }\n  }\n}\n# then: terraform init -upgrade=false","handlingStrategy":"validation","validationCode":"# in config, assert provider/terraform version compatibility before runs that write state\ncheck \"versions\" {\n  assert {\n    condition     = can(regex(\"5\\\\.\", data.tfe_provider.this.version))\n    error_message = \"provider version incompatible with WriteStateBytes; upgrade\"\n  }\n}","typeGuard":null,"tryCatchPattern":"# isolate the failing resource and pin the provider while reporting the bug\nterraform { required_providers { x = { source = \"acme/x\", version = \"=1.2.3\" } } }","preventionTips":["Keep Terraform/OpenTofu and providers on mutually compatible protocol versions.","Run new/updated providers in a scratch workspace before applying to real state.","Capture TF_LOG=TRACE provider output when you first integrate a provider so a zero-byte WriteStateBytes is caught early.","Watch provider release notes for WriteStateBytes/state-handling fixes."],"tags":["state","plugin","grpc","bug"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}