fix(nextly): apply related-row field rules to a single's write response - #381
Conversation
|
Warning Review limit reached
Next review available in: 24 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@codex please review this PR |
@nextlyhq/adapter-drizzle
@nextlyhq/adapter-mysql
@nextlyhq/adapter-postgres
@nextlyhq/adapter-sqlite
@nextlyhq/admin
@nextlyhq/admin-css
@nextlyhq/blocks-engine
create-nextly-app
nextly
@nextlyhq/plugin-form-builder
@nextlyhq/plugin-page-builder
@nextlyhq/plugin-sdk
@nextlyhq/plugin-seo
@nextlyhq/storage-s3
@nextlyhq/storage-uploadthing
@nextlyhq/storage-vercel-blob
@nextlyhq/ui
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1d001b550d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The write response expands relationships, and those rows carry the target collection's own field-level read rules. This path forwarded no caller, so it returned every related field intact - including ones the same caller's GET withholds, which made the write path a way around the rule. The writer supplied a relationship id, not the related row's protected fields, so the rule that applies is the target collection's own. Enforcement is keyed on a caller being present rather than switched on unconditionally: a trusted or internal write forwards none, and stripping there would hide fields from a writer nothing denied.
1d001b5 to
4c29268
Compare
|
Rebased onto #380 restored second-hop expansion for code-first collections. That lands in exactly the path this PR redacts: a code-first write response can now reach a related row's own relationships, and before this change every one of those came back unredacted too — so #380 widened the surface this closes. Verified rather than assumed that the caller propagates that far: added a third integration test with a Re-measured on the rebased branch: unit 400 failed, unchanged from |
|
@codex please review this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4c292685f1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Keying enforcement on a user being present left an anonymous caller - one a public update rule admits - reading related fields their own GET strips. Absence of a user is not trust; overrideAccess is, and the expansion helper already short-circuits on it. This matches the read path, which enforces for every caller and bypasses only on overrideAccess. Also drops a PR reference from a test docblock: comments describe the code, not the history that produced it.
|
@codex please review this PR |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Task 057, slice 2 — the Singles half.
What is wrong
SingleMutationService.updateexpands relationships for its response and forwards no caller:Those rows belong to another collection and carry that collection's field-level
access.readrules. Read paths have evaluated them since #335; this path never did, so it returned every related field intact — including ones the same caller'sGETwithholds. That makes the write path a way around the rule: write anything, read the response back.The decision this needed, and why it went this way
057 flags that mutation responses deserve a deliberate call rather than letting the answer fall out of the wiring: should a writer see related fields their own read rules deny?
They should not, and the reasoning is the codebase's own. #335 established that related-row rules are the target collection's decision — "the same decision the related row would get if it were read directly". A mutation response is a read of that row. And the counter-argument ("they just supplied the data") does not reach these fields: the writer supplied a relationship id, not the related row's protected columns. Nothing about writing a Single entitles you to read another collection's hidden fields.
The trap, and how it is avoided
#338 proved twice that setting
enforceFieldAccess: trueunconditionally strips fields from entitled callers, because "no caller supplied" and "anonymous" are indistinguishable at that layer. So enforcement here is keyed on a caller actually being present:A trusted write (
overrideAccess) and an internal write that forwards no user are unaffected. That is the same opt-in discipline every other surface uses, and it is why the second test below exists.Verification
Two integration tests against a real database:
The first was confirmed to fail on current
mainbefore any fix (expected { …(8) } to not have property "suspended"). Baselines after a full build: unit 400 failed both before and after, zero failing tests unique to this branch (name-set comparison); integration 708 → 710 passed, zero failures.Scope
Singles only. The collection half (
collection-mutation-service.ts) is deliberately left out: #378 is currently editing that file, and this decision applies there identically once it lands. Component-nested relationships on the write path remain withtasks/left-tasks/062, which is scoped as loader-side work.Confirmed not already done or in flight
The test fails on current
main, the call site still passes onlyfieldConfigs, and no open PR touchesenforceFieldAccess.