hashicorp/terraform · error
expected on 1 response value, got
Error message
expected on 1 response value, got: %d
What it means
Defensive check after a successful single-op transaction. The store() closure submits exactly one KVTxnOp, so Consul must return exactly one result. If len(resp.Results) != 1, the protocol contract is violated; the message says 'expected on 1 response value' (a typo in source for 'only'). This branch is not expected to fire in practice.
Solutions
- Capture the Terraform version, Consul version, and the full Txn response and file a bug against the consul remote-state backend.
- Retry the operation once; a transient Consul quirk is the only realistic non-bug cause.
- Check Consul health (`consul info`) for unusual signs.
Defensive patterns
Strategy: try-catch
Try / catch
// This branch is defensive; treat as a bug and retry once, then surface clearly.
diags := remoteClient.Put(data)
if diags.HasErrors() && strings.Contains(diags.Err().Error(), "expected on 1 response value") {
log.Printf("consul txn returned unexpected result count; retrying once")
diags = remoteClient.Put(data)
}
if diags.HasErrors() {
return fmt.Errorf("unexpected consul response shape (tf=%s, consul=%s): %w", tfVersion, consulVersion, diags.Err())
} Prevention
- Pin Consul and Terraform versions that are known-good together.
- Capture full Txn responses in logs so hits can be reported upstream.
- Don't rely on this branch being unreachable in custom forks; keep the assertion.
When it happens
Trigger: store(payload) -> ok==true but len(resp.Results) != 1.
Common situations: A Consul version returning an unexpected Txn response shape; an upstream Consul API change; essentially an impossible branch. Treat any hit as a bug.
Related errors
- state already locked
- consul CAS failed with transaction errors
- Error initializing backend %T
- Error unlocking Consul state. Lock ID
- error unmarshaling lock info
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/0911d25b8c14c024.
Report an issue: GitHub.
Appendix: 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 d32a084675)