jackc/pgx · error
argument of StrictNamedArgs not found in sql query
Error message
argument %s of StrictNamedArgs not found in sql query
What it means
StrictNamedArgs was given an argument that no placeholder in the SQL references. Strict semantics reject extra arguments, mirroring the unused-argument check in positional sanitization.
Solutions
- Remove the extra argument from the map
- Add the corresponding named placeholder to the SQL
- Switch to non-strict NamedArgs if extras are acceptable
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at named_args.go:201 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/6a77e874f169fac0.
Report an issue: GitHub.
Appendix: source
Thrown at named_args.go:201
case namedArg:
sb.WriteRune('$')
sb.WriteString(strconv.Itoa(l.nameToOrdinal[p]))
}
}
newArgs = make([]any, len(l.nameToOrdinal))
for name, ordinal := range l.nameToOrdinal {
var found bool
newArgs[ordinal-1], found = na[string(name)]
if isStrict && !found {
return "", nil, fmt.Errorf("argument %s found in sql query but not present in StrictNamedArgs", name)
}
}
if isStrict {
for name := range na {
if _, found := l.nameToOrdinal[namedArg(name)]; !found {
return "", nil, fmt.Errorf("argument %s of StrictNamedArgs not found in sql query", name)
}
}
}
return sb.String(), newArgs, nil
}
func rawState(l *sqlLexer) stateFn {
for {
r, width := utf8.DecodeRuneInString(l.src[l.pos:])
l.pos += width
switch r {
case 'e', 'E':
nextRune, width := utf8.DecodeRuneInString(l.src[l.pos:])
if nextRune == '\'' {
l.pos += width
return escapeStringStateView on GitHub (pinned to ec1a0befd2)