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
{{ message }}
Repository navigation
findVersionByID (collection and global) never runs sanitizeWhereQuery on the merged access-control where, unlike every other read operation #17883
Every other read operation sanitizes the merged where before handing it to the db layer: findByID.ts, findVersions.ts (line 110), countVersions.ts, find.ts, count.ts and findDistinct.ts all call sanitizeWhereQuery({ fields, payload, where }) on the combined access-control where so relationship-backed virtual fields referenced in an access function's returned where get rewritten to their real underlying path.
Both findVersionByID.ts (collections/operations/findVersionByID.ts) and its global counterpart (globals/operations/findVersionByID.ts) skip this step entirely, the merged where from combineQueries(where, accessResults) goes straight to payload.db.findVersions/findGlobalVersions.
Concretely: if a collection or global's access.readVersions returns a where constraint on a virtual field (e.g. a field defined as virtual: 'related.label'), every other read operation would resolve that to the real path first. findVersionByID doesn't, so the db layer gets an unresolvable virtual field path and the lookup silently returns nothing, the caller sees Forbidden/NotFound instead of the correct version.
I found PR #17804 which implements exactly this fix ("fix: sanitize where query on findVersionByID for inherited read access", explicitly noting "findByID, findVersions, and countVersions all sanitize the merged where in the same spot"), but it targets a feature branch (codex/pyld-3081-versions-access-control), not main, and I don't see any open or merged PR bringing it into main. Confirmed against the current main HEAD that both files still lack the sanitizeWhereQuery call.
Confirmed: PR #17634 (open, targeting main, changes-requested) already includes this exact fix — sanitizeWhereQuery calls added to both collections/operations/findVersionByID.ts and globals/operations/findVersionByID.ts, as part of its broader read-access-inheritance work. #17804 (referenced above) was a branch off that same work targeting the now-superseded feature branch. Since #17634 already carries this change on main-targeted code, I won't open a duplicate PR here — this should close once #17634 merges (or a maintainer can cherry-pick just this piece out sooner if #17634 stalls).
Activity
JarrodMFlesch commentedon Aug 21, 2026
The branch you mentioned is explicitly targeting the main branch? #17634
wakqasahmed commentedon Aug 23, 2026
Confirmed: PR #17634 (open, targeting
main, changes-requested) already includes this exact fix —sanitizeWhereQuerycalls added to bothcollections/operations/findVersionByID.tsandglobals/operations/findVersionByID.ts, as part of its broader read-access-inheritance work. #17804 (referenced above) was a branch off that same work targeting the now-superseded feature branch. Since #17634 already carries this change on main-targeted code, I won't open a duplicate PR here — this should close once #17634 merges (or a maintainer can cherry-pick just this piece out sooner if #17634 stalls).