Repository navigation
fix(plugin-sharing): refuse an unresolved user recipient on the sys_sharing_rule /data door - #39361
objectstack-fleet[bot] wants to merge 4 commits into
Conversation
…haring_rule /data door The Setup sharing-rule form writes through POST /api/v1/data/sys_sharing_rule, which never reaches defineRule, so a rule whose `user` recipient named no user (or no member of the rule's organization) was stored and granted no one access. bindRuleRecipientGuard refuses that insert, and an update that moves a rule onto such a recipient, with defineRule's own verdict and sentence (SharingService.userRecipientRefusal), VALIDATION_FAILED under recipient_id. System writes and updates that keep the stored recipient are not judged. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZVKCmRkE5bj7Rwba3
📓 Docs Drift CheckThis PR changes 1 package(s): 39 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 7 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 12 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 64eeba406442f3b3402cb093de513c7dc26268f7 && git checkout 64eeba406442f3b3402cb093de513c7dc26268f7
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 5788b130725ea58c1e8ca511c082849ef5f933f8 1b8a19562b6ef62c82ec0977fb4c40f565a5c2f6 && git checkout -B drift-repro 5788b130725ea58c1e8ca511c082849ef5f933f8 && git merge --no-ff 1b8a19562b6ef62c82ec0977fb4c40f565a5c2f6
node scripts/docs-audit/affected-docs.mjs --json 5788b130725ea58c1e8ca511c082849ef5f933f8
|
- changeset: answer the ADR-0087 question for the narrowing (not-required, no-migration-prescription). - system-context page: row 40 names bindRuleRecipientGuard, whose system-context early return is an elevation read; register regenerated. - runtime declared-name pin: author its rows to the dev admin's real user id, since the data door now refuses a user recipient that names no user. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZVKCmRkE5bj7Rwba3
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZVKCmRkE5bj7Rwba3
|
repo:objectstack@os-bill · os-bill · session_01Utp6CaJjkQx5fPE4Fbmoeq Contract reviewServed-tier: Inputs read: card #38254 (body, triage 7240297066, unlock 7241733218, claim 7381546986, amendments 7382578933 and 7382609355; no ruling, no earlier record), PR #39361 (body, 6 files, net diff against merge base ① Derived judgments
② Semver level
Two things for the lane seat on the prose faces, neither part of ④:
③ Boundary flags
④ Design judgment
No must-fix.
Check-runs on the head, all Implemented-by: VERDICT: PASS |
… pin the organization arms Review round 1 on the recipient guard: - the organization a write is judged in is the one it leaves the rule in: a supplied organization_id first, then the stored row's, then the caller's active organization; each arm has a pin that turns red without it; - the runtime door pin asserts the 400 VALIDATION_FAILED envelope; - the changeset carries the BREAKING line and the caller's fix; - the sharing-service and sharing-rules pages name the /data door refusal. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZVKCmRkE5bj7Rwba3
|
repo:objectstack@os-bill · os-bill · session_01Utp6CaJjkQx5fPE4Fbmoeq Contract reviewServed-tier: Delta review. Round 1 is the record on ① Derived judgments
② Semver level
This matches AGENTS.md step 3 for a non-protocol narrowing at The PR body now carries
③ Boundary flags
④ Design judgment
The PR body's ablation report (each of the three arms turns exactly its own pin red) agrees with this reading. CI ran the file in
Findings from round 1:
New:
No must-fix. No should-fix open. Check-runs on this head, all
Implemented-by: VERDICT: PASS |
|
repo:objectstack@os-bill · os-bill · session_01Utp6CaJjkQx5fPE4Fbmoeq 席位核对ACCEPT (zone data-1203 L1, delta) · Head-sha:
|
|
repo:objectstack@os-bill · os-bill · session_01Utp6CaQsbKBMQtm6Tpsamd 维护者速读
席位核对ACCEPT · head
|
|
repo:objectstack@os-bill · os-bill · session_01Utp6CaQsbKBMQtm6Tpsamd Review request: 2026-12-03T16:47Z · |
Requested by Bill · project thread
Fixes #38254
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: updated here
维护者速读
POST /api/v1/sharing/rules早已(A manual record share to a user id that does not exist is accepted (201) and persists an inert sys_record_share row #33912)拒收这种接收人,但表单走/data门,绕过了那道检查。What changes
packages/plugins/plugin-sharing/src/rule-hooks.ts: newbindRuleRecipientGuard(beforeInsert/beforeUpdateonsys_sharing_rule, its own package idplugin-sharing:rule-recipient-guard). It refuses auserrecipient withSharingService.userRecipientRefusal(id, organization, 'rule'), the verdict and sentencedefineRuleuses, thrown asvalidationFailure(VALIDATION_FAILED, 400) with onefieldsentry underrecipient_id(invalid_value, the code plugin-auth's guards already use).user.userand differs from the pre-image (type or id), so a rule whose user has since left can still be switched off or edited.organization_idthe write supplies (on an update, a re-point the tenant wall admitted), else the stored row's, else the caller's active organization (the Setup form posts none). With none under a wall the verdict stands aside, as it does fordefineRule(the engine refuses that insert for every recipient alike).packages/plugins/plugin-sharing/src/sharing-plugin.ts: binds the guard next tobindRuleObjectEnforcementGuard.packages/plugins/plugin-sharing/src/sharing-rule-recipient-guard.test.ts: realObjectQL+SqlDriverpins, isolated, group and single posture, including one pin per organization arm (a form-shaped insert with noorganization_id, an update by a caller with no active organization, a re-pointing update).content/docs/permissions/system-context.mdx: the guard's system-context early return is an elevation read, so row 40 namesbindRuleRecipientGuardand the generated register is regenerated (check-system-context-census).packages/runtime/src/sharing-rule-declared-name.data-door.pin.test.ts: its authored rows named a made-upuserrecipient, which the new guard (bound first) now refuses before the declared-name guard the pin targets; they now name the signed-in dev admin's realsys_userid. A module-topimport '@objectstack/metadata'pays that package's lazy load (reached throughapp-plugin.ts) during collection instead of inside the first timed case, ascheck-test-source-aliasrequires for a changed test file that reaches it. One new case asserts the wire answer at the real door:400,VALIDATION_FAILED,fields[0].field === 'recipient_id', no row.content/docs/kernel/runtime-services/sharing-service.mdxandcontent/docs/permissions/sharing-rules.mdx: state the recipient refusal for the/datadoor too.patchchangeset for@objectstack/plugin-sharing(non-protocol narrowing: BREAKING line, the caller's fix, ADR-0087not-required).No new error code, export from the package index, or locale key.
Why
PR #38216 made
SharingService.grantandSharingRuleService.defineRulerefuse auserrecipient that resolves to no user, and named the/datadoor as unchanged. The Setup form writes through that door, so it kept storing inert rules that told the admin they saved.Verification
pnpm exec vitest run src/sharing-rule-recipient-guard.test.ts(plugin-sharing): 15 passed. With the bind commented out, every refusal case fails. Each organization arm ablated in turn (session arm removed; stored-row arm removed; pre-image ahead of the supplied value) turns exactly its own pin red.fields; a user of another organization answers the same code and sentence (id aside) as an unknown id; the/datasentence equalsdefineRule's; position recipient and system context pass; update moving onto an unresolved user (by id or by switching type) refused and the row unchanged; update keeping the stored recipient (and switching off) admitted; single posture refuses an unknown id and admits any existing user; the three organization arms above.pnpm exec vitest run src/sharing-rule-declared-name.data-door.pin.test.ts(runtime): 5 passed, the three 409 assertions unchanged.check-system-context-census,check-adr-0087-registration,check-test-source-aliasand ESLint on the changed files pass locally.Human Minimum
packages/specholds no runtime logic.pnpm lintpasses.main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (not touched)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01Utp6CZVKCmRkE5bj7Rwba3