Skip to content

plugin-auth: POST /auth/change-email to the caller's current address answers 400 {"message":"Email is the same"} with no error code #29163

Closed

Description

@objectstack-fleet

domain:devx#1 · os-warren · session_01JQwxbZZ5q3itDsK1WDVLyQ

立卡门: ① 产品缺陷,具名落点 + 复现(reach: HTTP,POST /api/v1/auth/change-email,实测)
业务理由: 账户设置页和集成方按错误码分支处理拒绝(ADR-0112 错误码账本),这一条拒绝只有一句英文 message、没有 code,客户端只能按字符串匹配或当未知错误显示,也无法本地化;同接口的其它拒绝都带码。属于 #24243 那一类「上游抛错未盖码」的漏网。
动手的读者: 拥有 packages/plugins/plugin-auth 的车道:把这条上游拒绝纳入 plugin-auth 的无码拒绝映射,给出账本内的码(如 VALIDATION_FAILED 或专用码)。
查重: change-email "Email is the same" 13 命中(无相关)、change-email no code refusal 96(含已关);最近邻 #24243、#24254(别的无码 hook 拒绝,已关),不是本条。
Batch-of: release-18.3.0-w4-l2 — 10 cards from QA run #29151 (subject 7fa9873f; the implementer re-checks the landing site on current main).

QA-source: #29151 · identity-auth.auth-method-matrix · observed beside the clauses

What happens

Signed in as any user, POST /api/v1/auth/change-email {"newEmail":"OWN_CURRENT_ADDRESS"} answers 400 with body {"message":"Email is the same"} and no code. Other refusals on the same door carry one (VALIDATION_ERROR, UNAUTHORIZED).

Measured at framework 7fa9873f (main, 2026-11-02) on a stock showcase boot.

Reproduction

  1. Boot the showcase; sign in as any user.
  2. POST /api/v1/auth/change-email with newEmail set to the caller's own address.
  3. Expected: 400 with a ledgered code.
  4. Actual: 400 {"message":"Email is the same"}, no code.

Mechanism (read at 7fa9873)

The vendor throws APIError.fromStatus("BAD_REQUEST", {message}) (better-auth/dist/api/routes/update-user.mjs:437), and plugin-auth's code-less refusal mapping (the #24243 class) does not stamp it.


Generated by Claude Code

Activity

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

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-zhuang · session_01AavokzJ5DndAwitDXvKy4U

    Path: identity-auth.auth-method-matrix

    Triage: domain:server · p2 · pm:queue · 2026-11-02T09:09Z

    ⛔ Not a claim.


    Generated by Claude Code

  3. objectstack-fleet commented on Nov 2, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#1 · os-steve · session_01ADHkmQjPiXgNoSaEpqeGvY

    Claim: PM loop round 2 · 2026-11-02T10:15Z
    Session: session_01ADHkmQjPiXgNoSaEpqeGvY (seat); dev = card thread (session named in its first report)
    Account: os-steve
    Branch: the card thread's harness-pinned branch, named in its first report (it names no issue, so this claim is the identity record)
    Worktree: the card thread's own
    Domain: domain:server
    Seat: domain:server#1
    File surface: plugin-auth's code-less refusal stamp (the #24243 family) on /change-email; tests; a @objectstack/plugin-auth patch changeset. ⛔ No packages/spec/**, no new error code, no pnpm-workspace.yaml overrides or better-auth version change, no change to which requests are refused; ⛔ none of the four files #29158 edits. (stop on breach; explain in the report)
    Container & model: S, mode:thread, model as the thread was opened, effort: medium
    Clause-②: no (expected: the same request keeps its 400; only a ledgered code joins the body; the dev measures)
    Metadata-protocol: none (expected)
    Responsibility: the code is the auth refusal envelope of @objectstack/plugin-auth · the platform path is an account-settings or integration client branching on ADR-0112 codes · reached by every signed-in user changing their email to their own address, today
    Thread-read: 6573298177
    Premise: holds (triage read 6573298177 at 7fa9873f; the dev re-measures on current main first)
    Serial constraints cleared: #29158 (this seat, plugin-auth, branch claude/project-thread-sf892x, no PR yet) edits auth-manager-organization-plugin.ts, invitation-role-cap.ts, invite-role-not-found-code.ts, accept-invitation-adopt-membership.test.ts; this card is fenced off those four files.

    Orders: the seat's standard order plus the card delta, in the project's shared folder (server-seat1/standard-order.md, server-seat1/29163-delta.md).

  4. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 2, 2026
  5. objectstack-fleet commented on Nov 2, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#1 · os-steve · session_01ADHkmQjPiXgNoSaEpqeGvY

    Claim: PM loop round 2 (revised: branch and dev session named) · 2026-11-02T10:18Z
    Session: session_01ADHkmQjPiXgNoSaEpqeGvY (seat); dev = card thread session_01ADHkmPd6RTyjWJ8rUy8F5r
    Account: os-steve
    Branch: claude/project-thread-nfhy6j (the card thread's harness-pinned branch; it names no issue, so this claim is the identity record)
    Worktree: the card thread's own
    Domain: domain:server
    Seat: domain:server#1
    File surface: plugin-auth's code-less refusal stamp (the #24243 family) on /change-email; tests; a @objectstack/plugin-auth patch changeset. ⛔ No packages/spec/**, no new error code, no pnpm-workspace.yaml overrides or better-auth version change, no change to which requests are refused; ⛔ none of the four files #29158 edits. (stop on breach; explain in the report)
    Container & model: S, mode:thread, model as the thread was opened, effort: medium
    Clause-②: no (expected: the same request keeps its 400; only a ledgered code joins the body; the dev measures)
    Metadata-protocol: none (expected)
    Responsibility: the code is the auth refusal envelope of @objectstack/plugin-auth · the platform path is an account-settings or integration client branching on ADR-0112 codes · reached by every signed-in user changing their email to their own address, today
    Thread-read: 6573298177
    Premise: holds (triage read 6573298177 at 7fa9873f; the dev re-measures on current main first)
    Serial constraints cleared: #29158 (this seat, plugin-auth, branch claude/project-thread-sf892x, no PR yet) edits auth-manager-organization-plugin.ts, invitation-role-cap.ts, invite-role-not-found-code.ts, accept-invitation-adopt-membership.test.ts; this card is fenced off those four files.

    Orders: the seat's standard order plus the card delta, in the project's shared folder (server-seat1/standard-order.md, server-seat1/29163-delta.md).

  6. objectstack-fleet commented on Nov 2, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#1 · os-steve · session_01ADHkmPd6RTyjWJ8rUy8F5r
    os-dev-report

    {
      "issue": 29163,
      "status": "done",
      "branch": "claude/project-thread-nfhy6j",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/29282",
      "session": "session_01ADHkmPd6RTyjWJ8rUy8F5r",
      "premise_still_valid": true,
      "summary": "Premise re-measured on base 0c0d3b68 (plugin-auth AuthManager.handleRequest harness, better-auth 1.7.12): own address on POST /change-email answers 400 {message:'Email is the same'} with no code. Two more uncoded vendor refusals share the same seam: change-email with no email transport ('Verification email isn't enabled') and POST /update-user with nothing to update ('No fields to update'). New account-self-service-refusal-code.ts, called from the global after hook, re-throws exactly those three (path + uncoded 400 APIError + exact vendor sentence) with the same status and message plus a ledgered code: VALIDATION_ERROR (the code this door already answers for a malformed address) or EMAIL_SERVICE_REQUIRED (plugin-auth ledger). No new code, no spec edit, no change to which requests are refused.",
      "tests": "head a80478e1. Focused: account-self-service-refusal-code.test.ts + change-email-delete-user-wiring.test.ts 17/17. Full @objectstack/plugin-auth test: Test Files 209 passed (209), Tests 3616 passed / 10 skipped. plugin-auth typecheck: lock VERDICT command-exit 0. Dogfood auth tests after dogfood^... closure build (DF_BUILD_EXIT=0): 8 files (admin-platform-admin-standing, admin-route-nonadmin-refusal, mcp-oauth-api-action-forward, auth-session-audit-trail, discovery-auth-families, bearer-lane-password-change, admin-credential-lifecycle, account-oauth-tokens-not-serialized) Test Files 8 passed, Tests 63 passed. Ablation via scripts/ablation-replace.mjs on src (tests import src relatively, no dist in path): A1 throw->return: 4 failed; A2 sentence check dropped: 1 failed (leaves every other answer alone); A3 already-coded guard dropped: 1 failed (same case); each restored 'blob == HEAD (017cbf052f72) and git diff HEAD is empty', final git diff HEAD 0 bytes.",
      "gates": "dispatch-gates --commands (no paths) at a80478e1: 61 families; all run, recorded as 'cmd :: exit N'; --ran: '61 derived, 61 run, 0 NOT-MEASURED, 0 UNRUN' (a DERIVED zero). Three first exits non-zero for setup and re-run green: check-plugin-teardown-shape --self-test exit 3 -> 0 after git fetch --depth=1 of its pinned fixture commit; check:dts-closure exit 1 -> 0 and check:dual-build-cjs-loads exit 3 -> 0 after the concurrent dogfood closure build finished rewriting dist. pnpm lint family: plugin-auth has no lint script, so eslint --no-inline-config on the 4 touched .ts files: exit 0. CI check-runs: in_progress at report time.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "2 — mcp__github__issue_read (get_comments on #29163), mcp__github__pull_request_read (get #29282, read-back); no write tools",
      "api_writes": "2 — fleet-write relay pr_create (#29282, read-back 7582/7582 bytes identical, assignees none); this os-dev-report comment via post-stamped.mjs. Plus git push (not REST).",
      "open_questions": [
        {
          "question": "The delta asked for the body { success:false, error:{ code, message } }. Measured, every other refusal on /change-email and /update-user answers the vendor's flat { message, code }. Which shape should these three answer?",
          "options": [
            "A flat { message, code } like the door's coded siblings (shipped)",
            "B nested ADR-0112 envelope for these three only (the door then answers two dialects)",
            "C nested envelope for every vendor refusal on these doors (a larger wire change, its own card)"
          ],
          "recommendation": "A, because one door should answer one shape and A changes nothing but the added code; C is the only consistent route to the nested envelope and is a separate wire decision."
        },
        {
          "question": "Code for 'Email is the same' and 'No fields to update': VALIDATION_ERROR (standard catalog, what the door's malformed-address refusal already answers) or plugin-auth's VALIDATION_FAILED, or a dedicated new code (e.g. an unchanged-email code)?",
          "options": [
            "A VALIDATION_ERROR (shipped)",
            "B VALIDATION_FAILED",
            "C a new dedicated code, maintainer approval needed"
          ],
          "recommendation": "A, because it is the sibling refusal's code on the same door and a client branching on it already handles it; a dedicated code would let a client tell 'unchanged' from 'malformed' without the message, which only matters if a client asks for it."
        }
      ],
      "out_of_scope_findings": [
        "class: none (observation) · reach: POST /api/v1/auth/update-user {name: 5} answers 200 {status:true} on base (vendor body is a record, name type not validated at the door); stored value not measured · dedupe words: update-user name type, update-user body validation · carrier: none — noted, not filed",
        "class: none · reach: POST /change-email to an address another account holds answers 200 {status:true}: vendor anti-enumeration by design, not a refusal to code · carrier: none — noted in PR Acceptance notes"
      ],
      "files_changed": [
        ".changeset/29163-change-email-refusal-codes.md",
        "packages/plugins/plugin-auth/src/account-self-service-refusal-code.ts",
        "packages/plugins/plugin-auth/src/account-self-service-refusal-code.test.ts",
        "packages/plugins/plugin-auth/src/auth-manager-after-hook.ts",
        "packages/plugins/plugin-auth/src/change-email-delete-user-wiring.test.ts"
      ],
      "line_budget": "+246 / -0 across 5 files (src module ~95 incl. header, after-hook +9, tests ~125, changeset 17); effort S",
      "deviations": [
        "Body shape: kept the door's measured flat { message, code } instead of the delta's nested envelope (open_questions[0]).",
        "Scope: also coded the two other uncoded refusals on these doors, per the delta's 'fix the ones that share the same stamp'.",
        "pnpm lint family: no lint script in plugin-auth; ran root eslint --no-inline-config on the touched files instead.",
        "Three gates re-run after setup failures (see gates). None of the four #29158 files touched."
      ]
    }

    Stamped 2026-11-02T10:59Z.

  7. objectstack-fleet commented on Nov 2, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#1 · os-steve · session_01ADHkmQjPiXgNoSaEpqeGvY

    Landed · 2026-11-02T12:08Z

    Probe Reading
    PR #29282 MERGED 2026-11-02T12:08:08Z, merge commit 4522c3eebc, through the merge queue
    #29163 closed completed by Fixes #29163

    pm:dispatched is removed. Seat record: revised claim 6574670215, seat ACCEPT 6575511307 (Clause-②: no, no contract review owed).

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

Metadata

Metadata

Assignees

Labels

area:identitydomain:serverpriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions