{"record":{"id":"92cb03a65270a42b","repo":"hashicorp/terraform","slug":"failed-to-negotiate-acceptable-chunk-size-expecte","errorCode":null,"errorMessage":"Failed to negotiate acceptable chunk size. Expected size > 0 and <= %d bytes, provider wants %d bytes","messagePattern":"Failed to negotiate acceptable chunk size\\. Expected size > 0 and <= (.+?) bytes, provider wants (.+?) bytes","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/pluggable/pluggable.go","lineNumber":129,"sourceCode":"\tvar diags tfdiags.Diagnostics\n\treq := providers.ConfigureStateStoreRequest{\n\t\tTypeName: p.typeName,\n\t\tConfig:   config,\n\t\tCapabilities: providers.StateStoreClientCapabilities{\n\t\t\t// The core binary will always request the default chunk size from the provider to start\n\t\t\tChunkSize: chunks.DefaultStateStoreChunkSize,\n\t\t},\n\t}\n\tresp := p.provider.ConfigureStateStore(req)\n\tdiags = diags.Append(resp.Diagnostics)\n\tif diags.HasErrors() {\n\t\treturn diags\n\t}\n\n\t// Validate the returned value from chunk size negotiation\n\tchunkSize := resp.Capabilities.ChunkSize\n\tif chunkSize == 0 || chunkSize > chunks.MaxStateStoreChunkSize {\n\t\tdiags = diags.Append(fmt.Errorf(\"Failed to negotiate acceptable chunk size. \"+\n\t\t\t\"Expected size > 0 and <= %d bytes, provider wants %d bytes\",\n\t\t\tchunks.MaxStateStoreChunkSize, chunkSize,\n\t\t))\n\t\treturn diags\n\t}\n\n\t// Negotiated chunk size is valid, so set it in the provider server\n\t// that will use the value for future RPCs to read/write state.\n\tcs := p.provider.(providers.StateStoreChunkSizeSetter)\n\tcs.SetStateStoreChunkSize(p.typeName, int(chunkSize))\n\tlog.Printf(\"[TRACE] Pluggable.Configure: negotiated a chunk size of %v when configuring state store %s\",\n\t\tchunkSize,\n\t\tp.typeName,\n\t)\n\n\treturn resp.Diagnostics\n}\n","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/pluggable/pluggable.go#L111-L147","documentation":"Thrown by Pluggable.Configure after ConfigureStateStore when the provider's response Capabilities.ChunkSize is 0 or exceeds chunks.MaxStateStoreChunkSize (128 MiB). The core always requests chunks.DefaultStateStoreChunkSize (8 MiB); a provider may counter-propose a size, but it must be within (0, 128MB]. Zero indicates the provider never set the field.","triggerScenarios":"A state-store provider's ConfigureStateStore RPC returns resp.Capabilities.ChunkSize == 0 (struct left uninitialized) or a value > 128<<20. This happens with a buggy or version-mismatched third-party state store provider, or a provider built against an older chunks contract.","commonSituations":"Early/preview state-store providers that do not populate Capabilities; a provider compiled against a different revision of the providers.StateStoreClientCapabilities struct; a provider that intentionally tries to disable chunking by returning 0.","solutions":["Upgrade the state-store provider to a release that correctly populates Capabilities.ChunkSize in ConfigureStateStore.","If you author the provider, set ChunkSize to a value in (0, 128MiB]; reuse chunks.DefaultStateStoreChunkSize unless you have a reason to change it.","Verify the provider and Terraform core are built from compatible SDK versions (check the chunks package constants they link).","If you cannot upgrade, switch to a built-in backend (local, s3, azurerm, etc.) until the provider is fixed."],"exampleFix":"// provider side: ConfigureStateStore handler\n// before\nresp.Capabilities = providers.StateStoreClientCapabilities{}\n// after\nresp.Capabilities = providers.StateStoreClientCapabilities{\n    ChunkSize: chunks.DefaultStateStoreChunkSize, // 8 MiB, within (0, 128 MiB]\n}","handlingStrategy":"validation","validationCode":"// Provider side: validate before returning ConfigureStateStore.\nconst minChunk, maxChunk int64 = 1, chunks.MaxStateStoreChunkSize\nif resp.Capabilities.ChunkSize < minChunk || resp.Capabilities.ChunkSize > maxChunk {\n    resp.Capabilities.ChunkSize = chunks.DefaultStateStoreChunkSize // safe default\n    resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf(\"provider returned invalid chunk size; using default\"))\n}","typeGuard":"null","tryCatchPattern":"if diags := pluggable.Configure(cfg); diags.HasErrors() {\n    if strings.Contains(diags.Err().Error(), \"Failed to negotiate acceptable chunk size\") {\n        // provider bug: upgrade or switch backend\n    }\n    return diags\n}","preventionTips":["When authoring a state-store provider, always populate Capabilities.ChunkSize within (0, 128 MiB].","Pin Terraform and your provider to compatible SDK releases; renegotiation fields are version-sensitive.","Add a provider test asserting ConfigureStateStore returns a chunk size inside the legal range."],"tags":["pluggable-backend","state-store","provider","negotiation","chunk-size","grpc"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}