hashicorp/terraform · error
expected on 1 response value, got: %d
Error message
expected on 1 response value, got: %d
What it means
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.
Source
Thrown at internal/backend/remote-state/consul/client.go:251
},
}
ok, resp, _, err := kv.Txn(txOps, nil)
if err != nil {
return err
}
// transaction was rolled back
if !ok {
var resultErr error
for _, respError := range resp.Errors {
resultErr = errors.Join(resultErr, errors.New(respError.What))
}
return fmt.Errorf("consul CAS failed with transaction errors: %w", resultErr)
}
if len(resp.Results) != 1 {
// this probably shouldn't happen
return fmt.Errorf("expected on 1 response value, got: %d", len(resp.Results))
}
c.modifyIndex = resp.Results[0].ModifyIndex
// We remove all the old chunks
cleanupOldChunks()
return nil
}
if err = store(payload); err == nil {
// The payload was small enough to be stored
return diags
} else if !strings.Contains(err.Error(), "too large") {
// We failed for some other reason, report this to the user
return diags.Append(err)
}
View on GitHub (pinned to c9def3e214)
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.
Defensive patterns
Strategy: try-catch
Try / catch
// This is an internal invariant; catch, log, and surface rather than crash
if d := client.Put(data); d.HasErrors() {
if strings.Contains(d.Err().Error(), "expected on 1 response value") {
log.Printf("consul transaction returned unexpected results; report upstream")
}
return d
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- consul CAS failed with transaction errors: %w
- The remote state does not match the expected hash
- error unmarshaling lock info: %s
- state %q already locked
- failed to read state: %w
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/0911d25b8c14c024.
Report an issue: GitHub.