Skip to content

fix(plugin-auth): a reset link refused as a duplicate answers the uniform reset answer, not an empty 500 - #39787

Draft
objectstack-fleet[bot] wants to merge 5 commits into
mainfrom
claude/issue-32645-wip
Draft

objectstack-fleet[bot] wants to merge 5 commits into
mainfrom
claude/issue-32645-wip

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread
Fixes #32645
Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:在仍留有旧唯一索引的部署上,用户连续多次点「发送重置链接」时,忘记密码页不再出现红色的「status 500」报错,每次都得到与正常请求完全相同的提示。
  • 为什么做:这是忘记密码自助找回入口的加固,接手 os-bill 做了一半的工作;线上的根因已由云端删掉旧索引,这里让平台自身不再把这种拒绝变成空白 500。
  • 出错会怎样:只影响重置链接这一种写入,其它写入的拒绝方式不变;若有问题,直接撤回本 PR 即回到原来的 500 行为,不涉及数据变更。
  • 要你做什么:无。

What changes

Takes over os-bill's paused work (one WIP commit) and finishes it.

  • packages/plugins/plugin-auth/src/reset-request-duplicate-refusal.ts (new): when the store refuses an emailed reset link's sys_verification row (identifier prefix reset-password:) as a duplicate, the adapter answers null. better-auth 1.7.29's /request-password-reset reads a falsy createVerificationValue as a veto and answers the same 200 + uniform body it gives a sent link and an unknown address. Any other object, any other verification row, and any other refusal rethrows exactly as before.
  • objectql-adapter.ts create: the one insert call routes through insertOrVetoResetLink.
  • No conflict status on this door: a 409 would answer an address with an account differently from one without, which is the account-existence oracle the uniform answer exists to close.
  • The runtime warning names its remedy (drop the leftover unique index on sys_verification.value) and carries no tracker number.
  • The module header names the two doors this seam does not cover and why each needs nothing: a host secondaryStorage (better-auth still writes the cache copy of a vetoed row, so a cache-only link is mailed; the answer stays the uniform 200), and the phone reset door (its rows carry a random code in value, the phone's earlier row is deleted first, and a concurrent pair colliding on the derived row id is already recovered upstream by createOrFindVerification, which reads the driver error the engine keeps as cause).
  • Patch changeset for @objectstack/plugin-auth.

Read first, by risk:

  1. objectql-adapter.ts, the create hunk: the only line on a hot write path; everything except a reset link row must still throw.
  2. reset-request-duplicate-refusal.ts, isResetLinkRow / isDuplicateRefusal: the two predicates that bound the veto.
  3. reset-request-duplicate-refusal.test.ts, the "no existence oracle" case: the pin for the hard constraint.

Tests

  • New reset-request-duplicate-refusal.test.ts, against a real SQLite store carrying the leftover UNIQUE(value) index, through AuthManager.handleRequest:
    • a refused request answers exactly what a first request and an address with no account answer (status, content type and body all equal), with one link row in the table proving the refusal happened;
    • a burst of five concurrent requests for one account answers that same uniform 200 every time, sends one mail, and logs no error;
    • a second request sends no second mail;
    • unit cases bound the veto: other verification rows, other objects and other refusals rethrow.
Focused file, head 07975ef: 8 passed
pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/reset-request-duplicate-refusal.test.ts
      Tests  8 passed (8)
os-verify-lock: VERDICT command-exit 0
Ablation: the adapter call put back to a plain insert, 3 door pins red on the 500
ablation-replace: ok mutation landed: anchor 1 -> 0, blob ce0fa1c75ef7 -> ff274a65cbe3
     x a second reset request for one account answers 200 ...
     x answers a refused account exactly as a first request and an address with no account (no existence oracle)
     x a burst of five concurrent requests for one account answers the uniform 200 every time and logs no error
AssertionError: expected 500 to be 200
      Tests  3 failed | 5 passed (8)
ablation-replace: ok restored: blob == HEAD (ce0fa1c75ef7) and `git diff HEAD` is empty
Neighbouring reset, verification and adapter files: 17 files, 311 passed
pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 (17 files matching reset|objectql-adapter|verification|rate-limit-concurrency)
 Test Files  17 passed (17)
      Tests  311 passed (311)
Typecheck: green, test layer held at its ledger
pnpm --filter @objectstack/plugin-auth build && pnpm --filter @objectstack/plugin-auth typecheck
check:test-typecheck: OK — 10 file(s) / 71 error(s) / 23 pinned signature(s) held in test-typecheck-debt.json
os-verify-lock: VERDICT command-exit 0

NOT MEASURED: the full plugin-auth suite (299 files), reason: it does not finish inside the container's foreground cap; CI's Test Core carries it.

Acceptance notes

  • The card's original client-side rider (an in-flight guard on the forgot-password form) is outside this card's scope since the triage split: this card carries only the server half.
  • Under a host secondaryStorage, a vetoed row's link is kept in the cache only and mailed; the answer is still the uniform 200. Recorded in the module header and the changeset.
  • A host databaseHooks.verification.create.after hook receives null for a vetoed row (better-auth runs the after-hooks with what create returned). The platform registers none on verification.
  • node scripts/ci/snapshot-next.mjs --self-test exits 1 in this worktree on one stable-lane case; the diff does not touch scripts/.

Verification

Derived gate families (dispatch-gates --commands, reconciled with --ran): 71 derived, 69 run, 2 NOT MEASURED, 0 unrun
Run reconciliation — 71 derived, 69 run, 2 NOT-MEASURED, 0 UNRUN.
NOT MEASURED: pnpm check:dual-build-cjs-loads, reason: PREREQUISITE NOT MET (needs a whole-workspace build)
NOT MEASURED: pnpm check:query-options-erasure, reason: did not finish inside 280s on the shared box, twice
red, untouched path: node scripts/ci/snapshot-next.mjs --self-test (exit 1)
pnpm check:test-source-alias: red on the first run (the new test reached a dynamic egress import); fixed in 07975ef0, then exit 0

Two-minute check: pnpm --filter @objectstack/plugin-auth exec vitest run src/reset-request-duplicate-refusal.test.ts shows 8 passed; the "no existence oracle" case is the hard constraint.

🤖 Generated with Claude Code

https://claude.ai/code/session_016WV4cwiNRyb9B38wT2fjYj

… reset answer

Paused by the maintainer (p3 work paused); WIP pushed on his order.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CYxMdMFNAPYqMHvqBt
…known, add a burst pin

The refused reset request answers exactly what a first request and an
unknown address answer (status, media type, body), proven against a store
that really refused the row; five concurrent requests answer the same and
log no error. The runtime warning names its remedy instead of a tracker
number, and the module header names the two doors this seam leaves alone
(host secondaryStorage, the phone reset door) and why.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cwiNRyb9B38wT2fjYj
…engine read

The engine strips `identifier` on read, so the one-row proof reads the
sys_verification table itself.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cwiNRyb9B38wT2fjYj
…duplicate pins

`check:test-source-alias` finds the reach into a dynamic
`@objectstack/core/egress` import; pay it at module top, not inside a
clocked case.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cwiNRyb9B38wT2fjYj
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Dec 5, 2026
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-auth, touching 6 documentable anchor(s).

4 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/api/error-catalog.mdx (via DUPLICATE_RECORD (literal, a string literal in DUPLICATE_RECORD_CODE))
  • content/docs/automation/flows.mdx (via DUPLICATE_RECORD (literal, a string literal in DUPLICATE_RECORD_CODE))
  • content/docs/permissions/authentication.mdx (via createObjectQLAdapterFactory (symbol, a top-level function))
  • content/docs/protocol/kernel/error-handling.mdx (via DUPLICATE_RECORD (literal, a string literal in DUPLICATE_RECORD_CODE))

⛔ 1 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-4.mdx (via DUPLICATE_RECORD (literal, a string literal in DUPLICATE_RECORD_CODE))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • the SDK route bridge reached 71 of 255 client-bound route-ledger rows — the other 184 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 184: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 60 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 881809cf53e394c59704cb9ba100386fba74804a → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 602953d0201865e5cdd1ca3d6fce88b82df2fbfa — the merge of head 07975ef04183c94469c52cd0fcbdd270ab68fcaf into base 881809cf53e394c59704cb9ba100386fba74804a, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 602953d0201865e5cdd1ca3d6fce88b82df2fbfa && git checkout 602953d0201865e5cdd1ca3d6fce88b82df2fbfa
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 881809cf53e394c59704cb9ba100386fba74804a 07975ef04183c94469c52cd0fcbdd270ab68fcaf && git checkout -B drift-repro 881809cf53e394c59704cb9ba100386fba74804a && git merge --no-ff 07975ef04183c94469c52cd0fcbdd270ab68fcaf

node scripts/docs-audit/affected-docs.mjs --json 881809cf53e394c59704cb9ba100386fba74804a

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 881809cf53e394c59704cb9ba100386fba74804a → pass the list as
args.docs, on the commit named under Which tree this was computed on.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants