{"record":{"id":"0911d25b8c14c024","repo":"hashicorp/terraform","slug":"expected-on-1-response-value-got-d","errorCode":null,"errorMessage":"expected on 1 response value, got: %d","messagePattern":"expected on 1 response value, got: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/consul/client.go","lineNumber":251,"sourceCode":"\t\t\t},\n\t\t}\n\n\t\tok, resp, _, err := kv.Txn(txOps, nil)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// transaction was rolled back\n\t\tif !ok {\n\t\t\tvar resultErr error\n\t\t\tfor _, respError := range resp.Errors {\n\t\t\t\tresultErr = errors.Join(resultErr, errors.New(respError.What))\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"consul CAS failed with transaction errors: %w\", resultErr)\n\t\t}\n\n\t\tif len(resp.Results) != 1 {\n\t\t\t// this probably shouldn't happen\n\t\t\treturn fmt.Errorf(\"expected on 1 response value, got: %d\", len(resp.Results))\n\t\t}\n\n\t\tc.modifyIndex = resp.Results[0].ModifyIndex\n\n\t\t// We remove all the old chunks\n\t\tcleanupOldChunks()\n\n\t\treturn nil\n\t}\n\n\tif err = store(payload); err == nil {\n\t\t// The payload was small enough to be stored\n\t\treturn diags\n\t} else if !strings.Contains(err.Error(), \"too large\") {\n\t\t// We failed for some other reason, report this to the user\n\t\treturn diags.Append(err)\n\t}\n","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote-state/consul/client.go#L233-L269","documentation":"Internal invariant in store() (consul/client.go:251): after a single-op KV transaction succeeds, exactly one result is expected. If resp.Results has a length other than 1 it fires. Note the message itself has a typo ('expected on 1' rather than 'expected only 1'). Under the documented single-op usage this should be unreachable.","triggerScenarios":"len(resp.Results) != 1 after kv.Txn returned ok=true with a single KVTxnOp. Only possible if the Consul server or API client returns an unexpected number of results for a one-op transaction.","commonSituations":"A Consul server / consul-api version that changes transaction response shape; an exotic Consul build; effectively a programming or contract bug rather than a user error.","solutions":["Verify the Consul server version is compatible with the consul-api client version Terraform was built against.","Retry the terraform operation once; transient protocol oddities can clear.","Report it as a bug with consul-api / Terraform backend if it persists, since the code path assumes a single result.","Upgrade or downgrade Consul to a version known to honor the single-op transaction contract."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// This is an internal invariant; catch, log, and surface rather than crash\nif d := client.Put(data); d.HasErrors() {\n    if strings.Contains(d.Err().Error(), \"expected on 1 response value\") {\n        log.Printf(\"consul transaction returned unexpected results; report upstream\")\n    }\n    return d\n}","preventionTips":["Keep the Consul server version compatible with the consul-api client Terraform ships.","Monitor for this error in logs - it signals an environment/version mismatch, not a user mistake."],"tags":["consul","remote-state","internal","transaction","invariant"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}