Repository navigation
fix(ui)!: remove equality operators from hasMany relationship filters - #15423
nehaaprasad wants to merge 3 commits into
Conversation
|
The crash reported in #15387 was fixed in #15766, released in 3.82.0, but I closed this PR too quickly. The frontend change here is still valuable. Since array-valued Thank you for contributing and for following up on my feedback. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
WhereBuilder operator support packages/ui/src/elements/WhereBuilder/*, test/fields/collections/Relationship/e2e.spec.ts, test/a11y/WCAG.e2e.spec.ts |
The WhereBuilder uses in, not_in, and exists for single-target has-many relationship and upload fields. The default operator comes from the valid operator list. Tests cover operator choices and keyboard interaction. |
Saved-filter condition conversion packages/payload/src/database/migrations/hasManyRelationshipFilters/migrateWhere.* |
migrateWhere recursively changes eligible equals and not_equals constraints to in and not_in. Tests cover nested conditions, field types, preserved values, and conflicting constraints. |
Saved preset and preference migration packages/payload/src/database/migrations/hasManyRelationshipFilters/index.*, packages/payload/src/exports/migrations.ts, test/query-presets/*, docs/migration-guide/v4.mdx |
migrateHasManyRelationshipFilters scans configured presets and preferences in batches, updates changed filters, and returns the update count. Tests cover metadata preservation, query results, reruns, and editing migrated filters. The migration guide documents how to run the helper and its behavior. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant MigrationScript
participant migrateHasManyRelationshipFilters
participant PayloadDatabaseAdapter
participant migrateWhere
MigrationScript->>migrateHasManyRelationshipFilters: pass payload and request
migrateHasManyRelationshipFilters->>PayloadDatabaseAdapter: fetch preset and preference records
migrateHasManyRelationshipFilters->>migrateWhere: convert each saved where filter
migrateWhere-->>migrateHasManyRelationshipFilters: return converted filter
migrateHasManyRelationshipFilters->>PayloadDatabaseAdapter: update changed records
migrateHasManyRelationshipFilters-->>MigrationScript: return updated-record count
Merge Risk: 
Minimal · up to 65442
-
The filter UI and saved-filter migration are mergeable after normal checks; no actionable issue remains identified.
Security architecture risk: 
Low · up to 65442
-
The change is limited to Admin filtering and an explicitly invoked migration. The inspected list-loading path retains separate authorization checks, and the migration preserves ownership and access settings. Remaining risks concern changed filter results, concurrent edits, and backup-dependent rollback rather than a demonstrated authorization bypass.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- observed — The trusted migration can rewrite eligible saved filters across all users in both configured internal collections. Its writes target saved-filter records, not referenced content documents, and are not restricted to the invoking user.
Security Findings and Attack Paths
- inferred — No attacker-reachable invocation of the new privileged helper was established. Inspected callers use migration execution or tests. The package export requires trusted server-side handling; downstream custom handlers were not assessed.
Trust Boundaries and Controls
- observed — In the inspected Admin list path, preset retrieval enforces access independently of the saved where clause. The ordinary target collection query also uses overrideAccess:false and combines the saved selection with configured base filters. Broader membership results therefore do not themselves demonstrate an authorization bypass.
Resilience and Maintainability Implications
- inferred — Failure containment depends on transaction-capable execution with the supplied migration request. ID-only updates provide no explicit stale-write predicate, and offset pagination provides no independent stable snapshot. Concurrent saved-filter changes could therefore be overwritten or missed under insufficient isolation; cross-adapter behavior was not established.
Hardening Proposals
- proposed — Use a controlled migration window with saved-filter writes paused, verify transaction support for the configured adapter, and retain a tested backup until filter-result validation is complete. If online execution is required, consider conflict detection and stable pagination.
-
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title names the main change: removing the equality operators from hasMany relationship filters in the Admin UI. The changeset matches this, including the field-types, WhereBuilder, and migration changes. The title is concise and specific, and the 'fix(ui)!' prefix flags a breaking change.
Full details: Description check
-
Explanation
The description states that equals and not_equals are removed from Admin list filters for hasMany relationship and upload fields with one target collection. It also describes the new migrateHasManyRelationshipFilters helper, the upgrade steps, and the breaking-change impact. All of this matches the changeset.
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 14 files. (1 skipped: 1 unsupported.)
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
I explored narrowing this to 4.x and providing a migration for existing saved filters, but that uncovered a difference between the adapters. MongoDB supports exact-array matching with I’m going to pause this for now until we settle what these operators should mean across adapters and how to preserve existing functionality. The original Postgres crash is already fixed by #15766, so we have room to work through that separately. |
Removes
equalsandnot_equalsfrom Admin list filters forhasManyrelationship and upload fields with a single target collection. These fields offerin,not_in, andexists. Single-value fields and polymorphic fields keep their current operators.Adds
migrateHasManyRelationshipFiltersfrompayload/migrationsand upgrade instructions for saved query presets and legacy collection preferences. The migration preserves selected IDs, preset access, ownership, and unrelated preferences, processes records in batches, and can be run again safely.Breaking Changes
Users upgrading to Payload 4 with saved equality filters on these fields must migrate them before reopening or editing those filters:
Create a database migration and call
await migrateHasManyRelationshipFilters({ payload, req })from itsupfunction. The 4.x migration guide includes a complete example. Conflicting equality and membership constraints require manual review; the helper throws rather than overwriting either constraint.On MongoDB, array-valued equality previously compared the entire array. Membership filters match any selected ID (
in) or exclude all selected IDs (not_in), so filters relying on exact array equality can return different results after migration. API equality operators remain supported.The database fix for #15387 is already covered by #15766; this change targets the 4.x Admin UI and saved-filter migration.