Repository navigation
fix(plugin-auth): a SCIM PATCH of only the name parts recomposes a derived display name - #38181
Conversation
…rived display name Temporary pnpm patch on @better-auth/scim 1.7.12 (maintainer ruling record 6845302116, option C): setNamePart recomposes name.formatted, and through setFormattedName displayName, when name.formatted was composed from the parts before the part changed. An explicit name is never overwritten. Removed in the upgrade PR to the vendor release that ships the recompose; the regression pin scim-name-recompose.test.ts stays. Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude <noreply@anthropic.com>
…M name pin Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude <noreply@anthropic.com>
…im-name-recompose
📓 Docs Drift CheckNothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs. What this run could not see
Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
|
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8 L1: ACCEPT · head 席位核对
Landing — non-governed, ≤3000 lines: the seat lands it through the ordinary queue. |
|
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8 Landing · 2026-11-28T07:05Z · head
State: ready for review + auto-merge (L1 ACCEPT 7235697648). |
Fixes #32380
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
patches/@better-auth__scim@1.7.12.patch(new, written withpnpm patch/pnpm patch-commit): a TEMPORARY vendor patch by maintainer ruling record 6845302116 (option C), with a header naming the ruling and its removal condition. InsetNamePart, it recomposesname.formatted(and, through the vendor's ownsetFormattedName,displayName) with the vendor's owncomposeNamewhenname.formattedequalledcomposeNameof the parts before the part changed. Four lines indist/index.mjs; nothing else in the package moves.pnpm-workspace.yaml: thepatchedDependenciesrow beside the three existing patches, plus a note in the block's comment (ruling, what it fixes, who receives it, removal condition).patch-commitwrote the key intopackage.json'spnpmfield; it was moved here as the block's own comment prescribes, andpackage.jsonis unchanged.pnpm-lock.yaml: as pnpm wrote it (the patch hash on the@better-auth/scimsnapshot).packages/plugins/plugin-auth/src/scim-name-recompose.test.ts(new): the regression pin, every case throughAuthManager.handleRequest()with a real SCIM bearer on a real ObjectQL over better-sqlite3.No changeset,
skip-changeset: the published@objectstack/plugin-authtarball (files: dist, README.md, CHANGELOG.md) is byte-for-byte what it was;@better-auth/scimis an external dependency of its bundle, and a pnpm patch applies only to installs of THIS workspace (dev, CI, and the framework build base image built from it), never to an npm install of the published package. A changelog line would tell npm consumers about a fix their install does not get. Measured, see Verification.Read first (by risk)
patches/@better-auth__scim@1.7.12.patch, thesetNameParthunk: the derived test is a VALUE test (state.formattedName === composeName(state), read BEFORE the assignment). That line decides every case below, including the edge one.packages/plugins/plugin-auth/src/scim-name-recompose.test.ts, case (c): the edge where the value test and the vendor's own suite disagree.pnpm-workspace.yaml, thepatchedDependenciesnote: what removes the patch.Tests
Replaceonname.givenNameandname.familyName) and Okta path-less (replacewith dotted keys):displayName,name.formattedandsys_user.namemove to the new parts; an unrelated PATCH (title) afterwards keeps the new name (the vendor rewritessys_user.namefrom its storeddisplayNameon every profile PATCH).displayName(which seedsname.formattedat create) survives a part change; an explicitname.formattedsurvives, with thedisplayNamederived from it; adisplayNameset by an earlier PATCH survives while the derivedname.formattedmoves; adisplayNamesent in the same PATCH as the parts wins, in both operation orders.displayNameandname.formattedsupplied explicitly but EQUAL to the composed parts read as derived and move. Pinned on purpose, so the upgrade PR that removes the patch reads the reversal (Acceptance notes).Red without the patch, green with it (tree 58bebae, patch registration removed and reinstalled for the red run)
Red (patch row deleted from
pnpm-workspace.yaml,pnpm install, installed vendordist/index.mjscarrying 0 occurrences of the patched line):The two that pass red are the explicit-name controls, which assert preservation and hold either way. This red run is also the re-measure of the card's premise on current
main: both shapes still leave the old name.Green (registration restored with
git restore --source=HEAD,pnpm install --frozen-lockfile):Whole package, with the patch (tree 6206923)
pnpm --filter @objectstack/plugin-auth build && pnpm --filter @objectstack/plugin-auth typecheck && pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2, under the shared verify lock:Every other SCIM suite in the package (deactivation, manager and group projection, SSO adoption, transaction scope, refusal audit) runs over the patched vendor and stays green.
Final head
c40d3488e5is 6206923 plus a merge oforigin/main; that merge changes no file underpackages/plugins/plugin-auth,patches/,pnpm-lock.yaml,pnpm-workspace.yamlorpackage.json(git diff --stat 6206923a6 c40d3488e5 -- ...is empty). The re-run of the SCIM suites on the final head is NOT MEASURED: the shared verify lock was not acquired in three 9-minute windows behind another session's dogfood run. CI's Test Core runs the package on this head.Acceptance notes
@better-auth/scim's own suite atv1.7.12(and atmain, 1.7.28) carriespreserves explicitly supplied formatted and display names when patching one name part: create withdisplayNameandname.formattedbothAda Lovelaceand parts Ada / Lovelace, PATCHname.givenNameto Augusta, expect both names kept. The vendor stores no record of whether a name was supplied or composed, so the ruled test (the value testsetFormattedNamealready makes) reads that shape as derived and recomposes it toAugusta Lovelace; case (c) pins it. Every explicit name that differs from the parts is still kept (b). The upstream draft below changes that vendor test's fixture to an explicit name that differs from the parts; if the vendor wants the equal case preserved, the only fix is a persisted provenance bit, which is a larger vendor change.@objectstack/plugin-authresolves an unpatched@better-auth/scimuntil the vendor ships the recompose (ruling item 3).name.formatted= the primary email; a later PATCH that adds parts does not recompose it (the email is not composed from parts). Removing both parts one by one leavesname.formattedon the last single part (composeNameof nothing is empty, and an empty name is never written).pnpm patch-commitwritespatchedDependenciesintopackage.json'spnpmfield, duplicating the three existing rows there; the comment inpnpm-workspace.yamlalready says to move it, which this PR did.Verification
Two-minute check:
pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/scim-name-recompose.test.tsafterpnpm installand a build of@objectstack/plugin-auth's dependencies; expectTests 8 passed (8). Then delete the@better-auth/scim@1.7.12row frompnpm-workspace.yaml,pnpm install, re-run: expect6 failed | 2 passed (8).Local gates (the 61 derived families)
node scripts/pm/dispatch-gates.mjs --commandsderived 61 families for this change set; all 61 were run on the final headc40d3488e5, exit code captured before any pipe and recorded per line.--ranreconciliation:61 derived famil(ies) accounted for — 60 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3). 60 exited 0.pnpm check:type-check-debtexited 3 (prerequisite not met: the merge movedpackages/specand the package builds it re-measures were not refreshed, because the verify lock was not acquired); on the pre-merge head 58bebae it read0 ledger entr(ies) re-measured in 817.5s, 0 raw tsc error(s) total. It is NOT MEASURED on the final head; CI runs it.check:test-source-aliaswas red on the first draft of the new test (the SSO egress guard loaded inside a case) and is green after the module-top import.Published-content check (positive control included): after building
@objectstack/plugin-auth, the patched line occurs in 0 files of itsdist/, whiledist/index.jsanddist/index.mjsimport@better-auth/scimas an external dependency, so the tarball carries the vendor as a reference and none of its code.Upstream draft (for the maintainer to submit)
Against
better-auth/better-authmain(8c5c68010b,packages/scim1.7.28, wheresetNamePartis unchanged from 1.7.12). Agents cannot open it; NOT MEASURED against the vendor's own suite (its workspace was not installed here), so runpnpm --filter @better-auth/scim testbefore submitting.Title: fix(scim): recompose derived name.formatted and displayName when a name part changes
Description: A SCIM User PATCH that replaces only
name.givenNameand/orname.familyName(Microsoft Entra ID sends one path-addressedReplaceper part; Okta sends a path-lessreplacewhose value carriesname.givenName/name.familyNamekeys) updates the parts but leavesname.formatted,displayNameand the backing Better Auth user'snameon the old name.setNamePartstores the part and never recomposes, whilecomposeNameis used only by thename.formattedremove path, so an identity provider whose attribute mapping sends only the parts keeps showing the old name indefinitely; only adisplayNamePATCH or a full PUT moves it. This change recomposesname.formattedinsetNamePartwhen it equalledcomposeNameof the parts before the change, and letssetFormattedNamecarrydisplayNamealong when that was derived fromname.formatted, the same derived-value testsetFormattedNamealready makes. A formatted or display name that differs from the parts is never overwritten. One existing test changes:preserves explicitly supplied formatted and display names when patching one name partused an explicit name equal to the composed parts, which the stored state cannot tell from a derived one; its fixture now uses explicit names that differ from the parts, so it still pins preservation.Generated by Claude Code