jackc/pgx · error
cannot get param
Error message
cannot get param %d: %w
What it means
While unmarshaling a JSON-encoded Bind message, a parameter value could not be decoded — the wrapped error comes from the per-parameter JSON value extraction. This is used by tooling that serializes protocol messages as JSON.
Solutions
- Check the wrapped error for the JSON decoding detail
- Verify parameter values are valid JSON objects with a recognized type key
- Use base64 for binary parameter values
- Inspect the JSON structure against Bind.UnmarshalJSON expectations
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgproto3/bind.go:219 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of jackc/pgx@ec1a0befd2 (2026-08-04).
Data as JSON: /api/errors/315142f2801c3a11.
Report an issue: GitHub.
Appendix: source
Thrown at pgproto3/bind.go:219
DestinationPortal string
PreparedStatement string
ParameterFormatCodes []int16
Parameters []map[string]string
ResultFormatCodes []int16
}
err := json.Unmarshal(data, &msg)
if err != nil {
return err
}
dst.DestinationPortal = msg.DestinationPortal
dst.PreparedStatement = msg.PreparedStatement
dst.ParameterFormatCodes = msg.ParameterFormatCodes
dst.Parameters = make([][]byte, len(msg.Parameters))
dst.ResultFormatCodes = msg.ResultFormatCodes
for n, parameter := range msg.Parameters {
dst.Parameters[n], err = getValueFromJSON(parameter)
if err != nil {
return fmt.Errorf("cannot get param %d: %w", n, err)
}
}
return nil
}
View on GitHub (pinned to ec1a0befd2)