ERROR: could not determine data type of parameter $1

PostgreSQL can’t infer a parameter’s type from context (e.g. $1 IS NULL or SELECT $1).

Seen on: PostgreSQL

Meaning

Parameters used without a typed comparison need an explicit cast.

Common causes

  • $1 IS NULL checks
  • Parameters in SELECT lists
  • Optional filter patterns (col = $1 OR $1 IS NULL)

⚡ Quick fix

  1. Cast the parameter: $1::text, $1::int
  2. Build the filter in application code instead of the OR-IS-NULL pattern

Detailed fix by platform

PostgreSQL

  1. WHERE ($1::text IS NULL OR email = $1::text)

How to diagnose

  1. Parameter — Which $n lacks context?
  2. Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.