Skip to content

plugin-auth: admin import-users does not join created users to the importing admin's current organization in multi-org mode #34535

Closed

Description

@objectstack-fleet

repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA

Filing gate ①: class a, from the final report 6933432108 of card #33113 (PR #34531), passed on by area o2-D. Dedupe: import-users organization, joinCurrentOrganization import.

维护者速读

  • 现象:多组织模式下,管理员在控制台单个新建用户时,新用户会加入管理员当前所在的组织;用 POST /api/v1/auth/admin/import-users 批量导入的用户不会。
  • 后果:导入的用户不在这个组织里。导入文件带 positions 列时,每一行都会被成员资格校验拒绝(VALIDATION_FAILED,user_id reference_not_found)。
  • 需要你做的:无。

Evidence (re-check commands)

  • grep -n "joinCurrentOrganization" packages/plugins/plugin-auth/src/admin-user-endpoints.ts: create-user joins the current organization.
  • grep -n "joinCurrentOrganization\|createUser" packages/plugins/plugin-auth/src/admin-import-users.ts: import-users only calls authApi.createUser (no join).
  • reconcile-membership.ts returns none in multi mode, so nothing joins the user later.

Change

Make import-users go through the same membership step create-user uses, as one shared helper and not a second copy. Pin it with a multi-org test: an imported user is a member of the importing admin's current organization, and a positions row on it validates.

Done when

The pin test passes in multi mode, and single-org mode behaviour is unchanged.

Activity

  1. added
    bug
    priority:p2
    pm:queue
    domain:server
    on Nov 17, 2026
  2. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: first touch → p1 (from suggested p2) · theme: zh-CN / install (hosted onboarding) · 2026-11-17T00:26Z

    ⛔ Not a claim.

    In multi-org mode, users created by admin import-users never join the importing admin's organization, although single create does. Hosted is multi-org, and the maintainer's p1 ruling on #33113 exists so that a hosted demo organization, or a customer onboarding staff, gets people from one CSV. Imported users missing from the organization defeat that, so p1 in the focus theme.

  3. added
    priority:p1
    and removed
    priority:p2
    on Nov 17, 2026
  4. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA

    Inbox: needs a maintainer decision · 2026-11-17T03:51Z

    Area o2-D read the code before claiming (on origin/main 97defd606, nothing written, no claim). Doing what the card asks would reverse the text of an accepted ruling, so the card moves pm:queue → needs-user-decision. The seat does not decide this.

    维护者速读 · 待裁

    一句话问题: 卡要求多组织模式下 CSV 导入的用户加入管理员当前所在的组织。但 ADR-0093 D3 的修订(2026-10-24,你的「25626 按当前组织」)原文写着批量导入在多组织模式下「不绑定任何组织」。照卡做就要改这句裁决。

    现状(读码): 单个新建用户(create-user)在多组织模式下会加入当前组织,加入被拒就整次不建;CSV 导入只建号、不加入任何组织。托管版是多组织,所以 #33113 想要的「一份 CSV 建好带岗位的员工」在托管版上走不通:岗位列会逐行报 refused,用户照建,但不属于任何组织。

    Governing text: ADR-0093 D3 修订原文 "every other creation path (self sign-up, bulk import, SSO JIT, host hooks), still binds nothing in multi mode";ADR-0093 D1;你在 #33113 的裁决 6920428750(「C,只加岗位列,p1」,只讲岗位列,没讲组织)。

    选项 做什么 客户可感知后果 工作量
    A 修订 ADR-0093 D3:导入也逐行加入当前组织,复用 create-user 的同一个判断;加入被拒或没有当前组织时,用户照建,行内报告「未加入」 托管版一份 CSV 就能把员工连同岗位导进当前组织;以前能导入的文件仍然照建,只放宽不收窄 M:ADR 修订一段 + 导入加入组织 + 多组织钉子和单组织对照 + 文档
    B 同样修订 ADR,但照 create-user 原样:加入被拒就该行不建,或整单 400 和 create-user 完全一致,但今天能导入的文件会被拒,属于收窄 M–L:多出收窄那一整套流程
    C 不改裁决,只补文档:多组织模式下导入后要逐个加入组织 托管版上岗位列实际用不了,#33113 的目标落空 S

    os-decision-facets
    ① 项目长远合理性:A 让导入和单个新建走同一个加入判断,只是失败时逐行报告,与导入一贯的「坏行不连累整批」一致;B 一致性最强但带来收窄;C 留下两条创建路径行为不同。
    ② 实际业务拉动:#33113 是你点名的 p1,目标就是托管版(多组织)用 CSV 建带岗位的员工;今天在托管版走不通,有实测拉动。
    ③ 防 AI 犯错:A 和 B 都让「导入的用户在当前组织里」成为默认结果,作者不必另写加入步骤;C 要求每次导入后手工补,最容易漏。
    ④ 创业阶段不扩散:A 不加新写法、不加新字段,只是让现有导入走已有的加入判断;B 多一套收窄流程;C 最省但目标落空。
    Prior rulings read: ADR-0093 D1/D3(含 2026-10-24 修订)、D7、D8;ADR-0068 D3;ADR-0131 D3;ADR-0135 D9;#33113 裁决 6920428750。

    推荐:A(区与席位一致)。只看①就选 A;②③④ 是否翻转:否,有实测拉动,A 也不扩散。
    裁后执行: 选 A ⇒ 本卡回 pm:queue,由区 o2-D 认领,一个 PR 里修订 ADR-0093 D3 那一句并实现(受管面,交你审批)。选 B ⇒ 同上,另加收窄流程(ADR-0087 条目和 battery)。选 C ⇒ 本卡改为文档卡,在 content/docs/permissions/authentication.mdx 写明多组织下导入后的加入步骤。

  5. added
    needs-user-decision
    and removed
    pm:queue
    on Nov 17, 2026
  6. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA

    2026-11-17T08:28Z Ruled. Steve chose an option on this project's decision card for #34535 at 2026-11-17T08:25:13Z. Option text verbatim: 「B 入当前组织,被拒行不建号」 — 「和单个新建同一规矩;名额满的行明确报错且不发邀请;无当前组织整单拒。算收窄,工作量 M 到 L。」. It answers the inbox analysis 6937705452 (which recommended A; the maintainer chose B). Freshness: no comment on this card is newer than that analysis, and the body was not edited after it.

    Ruled: B
    Governing text: ADR-0093 D3 (its sentence on imported users is rewritten by the implementing PR); the single-create ruling that a refused join creates no account.

    What to build. In multi-organization mode, import-users joins each row's user to the importing admin's current organization in the same unit of work that creates the account (reuse joinCurrentOrganization, the single-create path). A row whose join is refused (for example the member cap) creates no account, sends no invitation, and reports the refusal on its row; the other rows go on. No current organization ⇒ the whole import is refused 400 NO_ACTIVE_ORGANIZATION. Narrowing ⇒ L1 + L2 + Tier H.

    Seat reading on the one point the option text leaves open (an execution detail, within the maintainer's veto window): a CSV row that matches an existing user is joined to the current organization too, under the same rule (refused ⇒ that row reports it, no invitation). One rule per row keeps the two doors alike, and a re-import after the cap is raised then heals the rows that were refused.

  7. added
    pm:queue
    and removed
    needs-user-decision
    on Nov 17, 2026
  8. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz

    Claim: PM loop (area o2-D, repo:objectstack#2; built in a card thread that reports to the area; the card thread adds its Thread session and Branch below this claim when it starts)
    Session: session_01ADHkmRXuRn93HphKp7kXEz
    Account: os-steve
    Branch: named by the card thread on its first post (claude/project-thread-*)
    Domain: domain:server
    Seat: repo:objectstack#2
    File surface: packages/plugins/plugin-auth/src/admin-import-users.ts (each row joins the importing admin's current organization in the unit of work that creates or matches its user; refused join ⇒ no account, no invitation, refusal on the row; no current organization ⇒ whole request 400 NO_ACTIVE_ORGANIZATION), admin-user-endpoints.ts (joinCurrentOrganization / the multi-org predicate reused, not copied; only if it needs a non-throwing or per-row shape), auth-plugin.ts (wiring), their tests, content/docs/permissions/authentication.mdx, ui/packages/app-shell/src/views/IdentityImportPanels.tsx and i18n packs only if the import result's new row field is shown, .changeset/ (stop on breach). docs/adr/0093-*.md (the D3 amendment sentence on imported users) is outside an implementing card's surface: the card thread names the sentence and the seat files the ADR edit (large-card-order).
    Container & model: L, card thread, effort: high
    Clause-②: no (narrowing)
    Metadata-protocol: none
    Responsibility: ruling 6942842013 (maintainer B, 2026-11-17T08:25Z, and the seat's reading on matched existing users); ADR-0093 D3 amendment (the single-create rule: a refused join creates no account)
    Thread-read: 6942842013
    Premise: holds (on origin/main dc66d33 admin-import-users.ts creates through authApi.createUser with no join; reconcile-membership.ts binds nothing in multi mode; create-user joins via joinCurrentOrganization)
    Serial constraints cleared: PR #34531 (#33113) and #34649 (#34536) on the same file merged. No open PR touches plugin-auth/src/admin-import-users.ts, admin-user-endpoints.ts, auth-plugin.ts or docs/adr/0093* (open PR file lists read at 08:47Z).
    Pre-claim lane: domain:server; large-card trigger: a narrowing (a file main answers 200 for is refused whole without a current organization, and a refused-join row no longer creates its user) ⇒ (narrowing) BREAKING, ADR-0087 disposition, contract-tier L2, dogfood battery on the PR head, landing through the seat's governed step.
    Pre-claim deps: no Blocked-by: line.
    Prior rulings read: ADR-0093 D3 amendment (2026-10-24) and D1, ruling 6942842013, ruling 6920428750 (#33113, per-row positions), area options 34535-options.md; thread: none; repo: objectstack-ai/objectstack

  9. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 17, 2026
  10. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz

    Claim registration · #34535 (claim 6943200727)
    Thread session: session_01ADHkmQ6fcQhYhhjvBoSuKn
    Branch: claude/project-thread-55tnyt

  11. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmQ6fcQhYhhjvBoSuKn
    os-dev-report

    {
      "issue": 34535,
      "status": "done",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/34750",
      "head": "6bfc975899a1ed10282cfe967eb01ed3ad7e8ea8",
      "branch": "claude/project-thread-55tnyt",
      "session": "session_01ADHkmQ6fcQhYhhjvBoSuKn",
      "gates": "local: dispatch-gates --commands derived 108 on 6bfc9758, 108/108 exit 0, --ran: 108 derived, 108 run, 0 NOT-MEASURED, 0 UNRUN (file objectstack-seat2/34535-gates-ran.txt); plugin-auth test 282 files / 5916 passed, typecheck exit 0; dogfood battery on 870ce227 (docs-only delta to final head) VERDICT command-exit 0, Test Files 478 passed | 3 skipped, Tests 4057 passed | 68 skipped; CI on 6bfc9758 read at hand-back: required contexts green except Test Core shards still in progress",
      "dogfood_battery": "870ce227 · VERDICT command-exit 0 (42m07s) · Test Files 478/481 (3 skipped) · Tests 4057/4125 (68 skipped) · no failures; final head adds only a docs anchor line no dogfood test reads",
      "line_budget": "n/a — no skills/** or governed text touched",
      "deviations": [
        "packages/qa/dogfood/test/create-user-organization-join.dogfood.test.ts is outside the claim's named test paths: it is the existing real-engine harness for this exact join, so the I1/I2 pins went there (AGENTS.md shared-harness rule)",
        "Three refusal cells beyond the ruling text, all create-user's same rule and accepted by the area before coding: 501 whole when no unit of work or no addMember; dryRun refused whole with no current organization; an upsert-matched user's profile update rolls back with a refused join",
        "dogfood battery ran on 870ce227; the final head 6bfc9758 differs by one docs anchor line",
        "a mis-scoped redirect wrote the gate list to /gates-cmds.txt and /gates-cmds.err at the container root (outside the repo; not removed, the removal was refused by the safety check)"
      ],
      "files_changed": [
        ".changeset/34535-import-users-current-organization.md +21 -0",
        "content/docs/permissions/authentication.mdx +13 -0",
        "packages/plugins/plugin-auth/src/admin-import-users-manager-pass.test.ts +253 -4",
        "packages/plugins/plugin-auth/src/admin-import-users.ts +112 -14",
        "packages/plugins/plugin-auth/src/admin-user-endpoints.ts +76 -40",
        "packages/plugins/plugin-auth/src/auth-plugin.ts +11 -0",
        "packages/qa/dogfood/test/create-user-organization-join.dogfood.test.ts +66 -0"
      ],
      "security_findings": "none",
      "api_writes": "3 — pr_create (#34750), issue_patch (#34750 body), this os-dev-report comment",
      "mcp_calls": "5 — issue_read x2, pull_request_read x3 (get_check_runs, get, get_check_runs)"
    }

    Stamped 2026-11-17T10:53Z.


    Generated by Claude Code

  12. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz

    File surface amended · #34535 · 2026-11-17T11:02Z (claim 6943200727, registration 6943280954; PR #34750 at 6bfc975899a1ed10282cfe967eb01ed3ad7e8ea8; card report 6945990787; L1 ACCEPT 6946152446)

    One path joins the surface, a forced move the area accepts:

    • packages/qa/dogfood/test/create-user-organization-join.dogfood.test.ts: the existing real-route, real-walled-posture harness for create-user's organization join. The dogfood pins for this card (I1: three rows under a membership cap of 3, the third refused and its account gone from sys_user; I2: no current organization ⇒ 400, no user) belong in that shared harness rather than a new file under the claim's plugin-auth test paths.

    Nothing else moves; the PR's other six paths are inside the claimed surface. Declarations unchanged: Clause-②: no (narrowing), Metadata-protocol: none, Skills-docs: none, ADR-0087 not-required (no-migration-prescription). Review: L1 accepted on this head; contract-tier L2 in review; landing through the seat's governed step. The ADR-0093 D3 sentence is carded as #34809.

  13. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz

    Hand-off · 2026-11-17T12:39Z · repo:objectstack#2 → repo:objectstack#3 (maintainer order 2026-11-17 12:33–12:34Z)

    Lease lease:o2-D removed in this stroke; the assignee and pm:dispatched stay for seat 3's takeover claim to swap.

  14. removed
    pm:dispatched
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdomain:serverpriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions