You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add safe_in() utility to prevent PostgreSQL 65K parameter limit errors
PostgreSQL's wire protocol limits bind parameters to 65,535 per
statement. When Django ORM's filter(field__in=python_list) generates
WHERE field IN ($1, $2, ..., $65536+), it exceeds this limit when
using server-side cursors (.iterator()).
This introduces a safe_in() utility that uses a custom Django lookup
(= ANY(%s)) for large lists, passing the entire list as a single
PostgreSQL array parameter regardless of size. For small lists, the
standard __in lookup is used unchanged.
Applied safe_in() to all vulnerable code paths in pulpcore:
- RepositoryVersion.get_content(), added(), removed()
- import_repository_version() content mapping
Also updated the test to use .iterator() so it reliably exercises the
server-side cursor path that triggers the parameter limit.
Assisted-By: claude-opus-4.6
Avoid exceeding PostgreSQL's 65,535 query parameter limit when filtering by large lists of IDs. This fixes `OperationalError` crashes during large import and copy operations involving more than 65,535 content units.
Added `safe_in()` to the plugin API for building `Q` objects that are safe for arbitrarily large value lists, avoiding PostgreSQL's 65,535 query parameter limit.
0 commit comments