Repository navigation
fix(plugin-auth)!: import-users joins each row to the administrator's current organization in multi-org mode - #34750
Conversation
…current organization in multi-org mode Claude-Session: https://claude.ai/code/session_01ADHkmQ6fcQhYhhjvBoSuKn Co-authored-by: Claude <noreply@anthropic.com>
…a refused row back on the real engine Claude-Session: https://claude.ai/code/session_01ADHkmQ6fcQhYhhjvBoSuKn Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmQ6fcQhYhhjvBoSuKn Co-authored-by: Claude <noreply@anthropic.com>
…eam declares it Claude-Session: https://claude.ai/code/session_01ADHkmQ6fcQhYhhjvBoSuKn Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 25 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 9 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 21 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 a63443cd71bf014db25aadc4e8a871bdb89e7574 && git checkout a63443cd71bf014db25aadc4e8a871bdb89e7574
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin f02f4f63707bd05ae2186ca63babd54bfe37abcc 6bfc975899a1ed10282cfe967eb01ed3ad7e8ea8 && git checkout -B drift-repro f02f4f63707bd05ae2186ca63babd54bfe37abcc && git merge --no-ff 6bfc975899a1ed10282cfe967eb01ed3ad7e8ea8
node scripts/docs-audit/affected-docs.mjs --json f02f4f63707bd05ae2186ca63babd54bfe37abcc
|
…Directly heading Claude-Session: https://claude.ai/code/session_01ADHkmQ6fcQhYhhjvBoSuKn Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz Final head for review: |
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 6bfc975 · 2026-11-17T11:00Z |
|
repo:objectstack#2 · os-steve · session_01ADHkmTHGRTjPqZAcBuo9WH 席位核对L1 first review · ACCEPT · head Checklist (read on GitHub at this head, not from the report)
Before landing (no head move)
Owed outside this PR
Owed after this
|
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract reviewServed-tier: Security-touching: yes ① Derived judgments
② Semver levelClause-②: no (narrowing)
③ Boundary flags
④ Design judgmentNo must-fix, no should-fix. The narrowing makes an existing refusal real; it does not take a declared capability away at the consumer. On
Implemented-by: VERDICT: PASS |
|
repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA Seat record · 2026-11-17T11:17Z · Head-sha: 6bfc975 维护者速读
席位意见:同意合并。按裁决 B 实现,超出裁决原文的三格(501、dryRun 无组织、upsert 回滚)都套用「和单个新建同一规矩」并已申报。 席位核对
|
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 44080198671 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
Requested by Steve · project thread
Fixes #34535
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no published skill teaches the admin import-users route (
git grep -n import-users -- skills/answers 0 lines on this head); the route is documented incontent/docs/permissions/authentication.mdx, updated here维护者速读
NO_ACTIVE_ORGANIZATION,和单个新建同码同句。upsert 匹配到的已有用户也按同一规矩加入。positions列每行都被成员资格校验拒掉,托管版用一份 CSV 建带岗位的员工走不通。packages/plugins/plugin-auth/src/admin-import-users.ts(inRowUnit与 createData/updateData 两处)、admin-user-endpoints.ts(抽出的settleCurrentOrganizationJoin,create-user 码句不变)、packages/qa/dogfood/test/create-user-organization-join.dogfood.test.ts(真引擎 I1/I2)。pnpm --filter @objectstack/dogfood exec vitest run test/create-user-organization-join.dogfood.test.ts,预期 5/5 绿:I1 前两行进当前组织、第三行因名额上限失败且库里没有这个用户;I2 无当前组织 400。What changes
Maintainer ruling 6942842013 on #34535 (option B,
Ruled: B): in multi-org modePOST /api/v1/auth/admin/import-usersfollows create-user's ADR-0093 D3 amendment rule, row by row.addMember) moves intosettleCurrentOrganizationJoininadmin-user-endpoints.ts; create-user calls it with its codes and sentences byte-identical (its existing multi-org suite is unchanged and green), and import-users calls the same function. No copy.400 NO_ACTIVE_ORGANIZATION; no unit of work or no organization plugin ⇒501 NOT_IMPLEMENTED. Nothing is created.inRowUnit): a created row'screateUserandjoinCurrentOrganizationrun insidecreateGrant.runAtomically(the engine transaction; better-auth's adapter writes join it as an ambient transaction, ADR-0067 D2). A refused join throws out of the unit, the account rolls back, and the row fails with the vendor's code and create-user's sentence. The temporary password and the invitation target are recorded only after the unit committed, and invitations go out afterrunImport, so a refused row gets neither.joinCurrentOrganizationgains an optionalaccount: 'created' | 'existing'argument so that refusal does not say "no user was created", and an existing member is reportedmembershipCreated: false; create-user passes nothing and is unchanged.getTenancyandgetCallerActiveOrganizationId(create-user's session reader) inauth-plugin.ts.user.import_runrow records the joinedorganizationIdin multi-org mode.content/docs/permissions/authentication.mdxBulk Import section states the rule.Tests
admin-import-users-manager-pass.test.ts— the file's shared table-backed harness gains a multi-org mode (a unit of work that really restores the tables on throw, a member cap refused with better-auth's code, and the grant-holder membership refusal on position assignment), and one new top-level describe with 10 cases: joins + positions validate; refused row rolled back with no invitation (invite) and no password (temporary); 400 whole, dry run too, asserted equal to create-user's settlement answer; 501 for no unit of work / noaddMember; dry run joins nothing; upsert joins and skips an existing member; upsert refusal rolls the profile back; CONTROL single-org.packages/qa/dogfood/test/create-user-organization-join.dogfood.test.ts— the existing real-route, real-walled-posture harness for create-user's join gains I1 (three rows underOS_ORG_MEMBERSHIP_LIMIT=3: two join the current organization, the third is refused and its account is gone fromsys_user) and I2 (no current organization: 400, no user). This file is outside the claim'splugin-authtest paths; it is the existing harness for this exact join, so the pin went there (AGENTS.md: a new pin goes into the component's shared harness file).Acceptance notes
FROM → TO, measured (multi-org mode unless stated):
mainanswers200, every row created, in no organization (dogfood I2 on the pre-fix build:created: 1)400 NO_ACTIVE_ORGANIZATION, create-user's sentence, nothing createddryRun: true200preview400 NO_ACTIVE_ORGANIZATION200, rows created501 NOT_IMPLEMENTED, create-user's sentence, nothing createdcreated: 3)failedwith the vendor's code, account rolled back, no temporary password, no invitation; other rows landpositionsrefused on every rowmemberof the current organization; itspositionsassignnot-required (no-migration-prescription)— no schema key, export or stored row changes; the moved answers are admin HTTP refusals.docs/adr/**is outside an implementing card's surface).rows[].codeis the vendor's code asmapAuthApiErrorreads it (ORGANIZATION_MEMBERSHIP_LIMIT_REACHEDin the unit pin); the import response gains no new field.Verification
Final head
6bfc9758(the only commit after870ce227is a one-line anchor fix incontent/docs/permissions/authentication.mdx).Local gate round on 6bfc975 — 108 / 108 exit 0
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 108 commands; each ran with stdin closed and its exit captured before any pipe;--ranreconciliation:108 derived, 108 run, 0 NOT-MEASURED, 0 UNRUN. File:/mnt/project-files/objectstack-seat2/34535-gates-ran.txt.First round on
870ce227: two non-zero, both fixed before this round —check-plugin-teardown-shape --self-testexit 3 (shallow clone: its pinned fixture commit fetched with--no-tags, then 48/48), andcheck:doc-anchorsexit 1 (#create-a-user→#create-a-user-directly, the commit above).Tests
pnpm --filter @objectstack/plugin-auth teston870ce227(after mergingorigin/mainf6f5b50aand a fullpnpm build): Test Files 282 passed (282), Tests 5916 passed | 10 skipped.pnpm --filter @objectstack/plugin-auth typecheck(incl.check:test-typecheck): exit 0 after typing the harness's unit-of-work mock as the seam declares it.create-user-organization-join.dogfood.test.ts: 5/5 on the fix.pnpm --filter @objectstack/dogfood testunder the verify lock on870ce227:VERDICT command-exit 0(42m07s), Test Files 478 passed | 3 skipped (481), Tests 4057 passed | 68 skipped (4125). The final head differs only in the docs line above, which no dogfood test reads.Ablations (one per changed behaviour, restore proven by blob == HEAD)
undefined, i.e.main's import): the new multi-org describe goes 8 failed | 2 passed — the two that stay green are the dry-run-joins-nothing case and the single-org CONTROL, which assert the absence of a join.runAtomicallyreplaced by a pass-through): 4 failed | 6 passed — the refused-row rollback (invite), the temporary-password case, the upsert rollback, and the commit bookkeeping of the happy path.plugin-auth/dist(ablation-dist-preflight: marker present in 2 built files), dogfood file: I1expected 3 to be 2(all three rows created, cap never reached), I2expected 200 to be 400(one user created in no organization); J1/J2 and the posture guard stay green. Restore leg rebuilt, marker absent from all 20 built files, tree clean.Generated by Claude Code