Repository navigation
fix(certification): block credential issuance when learner has no name (closes #4782) - #4799
Merged
Merged
Conversation
#4782) Closes #4782 — the safety net behind escalation #382. Even after the auth-callback Slack fallback and onboarding gate in #4781, an exotic auth path could still drop a learner at credential-issuance time without a name. Today that produced an email-on-certificate; now it produces a one-turn conversational recovery. - issueCertifierBadge returns a NAME_REQUIRED sentinel (without calling Certifier) when users.first_name is empty. The credential row is still awarded in user_credentials; only Certifier-side issuance is deferred. - checkAndFormatCredentials now also retries previously-deferred issuances on every call, so the post-set_my_name retry finalizes the certificate. - set_my_name (new learner-self tool in member-tools) wraps the same write-through-to-WorkOS path as the onboarding form. Sage's prompt rule ("Credential name recovery") tells her to ask for first+last on seeing the marker, call set_my_name, then check_credentials to finalize. - check_credentials (new tool) runs an award/issue pass on demand. Used by the recovery flow and safe for "did I earn anything new?" prompts. - NAME_REQUIRED_MARKER constant exported and referenced from all three sites (sentinel, warning line, Sage rule) so they can't drift — guarded by a unit test. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Code reviewer (must-fix): - issueCertifierBadge now reads name via resolveUserNameWithFallbacks with the live DB pool, not the closure-bound memberContext that goes stale after set_my_name writes through. Closes the loop where Sage set the name but check_credentials still saw the gate fire. - Deferred-issuance retry in checkAndFormatCredentials is bounded to a 24-hour window so we never re-issue a legitimately-issued older credential whose certifier_credential_id was nulled out-of-band. Code reviewer (should-fix): - Move "Credential earned!" line *after* the gate check so a gated attempt no longer announces the credential before deferring. - Dedupe toProcess via Set (awarded + deferred could overlap on a race between checkAndAwardCredentials and getUserCredentials). - Narrow IssueResult union to literal 'NAME_REQUIRED' instead of typeof-the-constant (which collapsed to plain string). - Marker test now also pins the source-reference count so a refactor that drops one of the three load-bearing sites fails loud. Security reviewer (should-fix): - Rate-limit set_my_name (per-user default cap: 60/10min) — bounds WorkOS updateUser calls. - Rate-limit check_credentials (same cap) — bounds fan-out to Certifier issuance API. Cache-invalidation scope: invalidateMemberContextCache() with no arg clears the whole cache. This matches the pre-existing PUT /api/me/name behavior in http.ts:7400 — narrowing both is a separate fix. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
added a commit
that referenced
this pull request
May 20, 2026
…repair (#4882) The repair script in server/src/scripts/repair-credential-recipient-names.ts now accepts a flag that skips credentials whose backfill value would be the user's email AND the email domain is a personal-email provider (gmail, hotmail, yahoo, icloud, etc.). Avoids surfacing personal-email PII on a publicly-shareable credential artifact. Corporate-email users still get repaired — their email is already public on business cards / LinkedIn. Personal-email users wait for the NAME_REQUIRED gate + set_my_name recovery flow (#4799) to populate their name in users.first_name; re-running the backfill then picks them up. Closes the cleanup loop for #4753 and #4760. Tom Hespos's two credentials in #4760 are unaffected — we have his real name in the users table, so the script writes "Tom Hespos" not his email. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced May 20, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #4782 — the credential-issuance safety net behind escalation #382. Even after the auth-callback Slack fallback and onboarding gate in #4781, an exotic auth path could still drop a learner at credential-issuance time without a name. Today that produces an email-on-certificate (
[email protected]); now it produces a one-turn conversational recovery.Pattern
Hard block + Sage conversational prompt — option (1) from the issue. Fits the "Sage tools just work" pattern from feedback memory (Sage handles errors conversationally, doesn't announce tool names).
What's new
NAME_REQUIRED_MARKERconstant — exported, referenced from all three sites (sentinel, warning line, Sage rule)server/src/addie/mcp/certification-tools.tsissueCertifierBadgereturns the marker (no Certifier call) whenusers.first_nameis emptycertification-tools.ts:428checkAndFormatCredentialsretries previously-deferred issuances on every call — that's the post-set_my_namefinalize pathcertification-tools.ts:535set_my_namelearner-self tool — wraps the same write-through-to-WorkOS path as the onboarding formserver/src/addie/mcp/member-tools.tscheck_credentialstool — runs an award/issue pass on demand (previously the only triggers werecomplete_certification_module/ exam)certification-tools.tsbuildCertificationContextFlow
complete_certification_module→checkAndFormatCredentials→issueCertifierBadgedetects no name → returnsNAME_REQUIRED_MARKERcheckAndFormatCredentialsemits a warning line containing the marker. Share links + specialist Slack notification are deferred.set_my_namewith what they saidcheck_credentials—checkAndFormatCredentialspicks up the deferred issuance via the new "already-awarded-but-unissued" path, calls Certifier with the real name, returns share links + fires specialist notificationTest plan
tests/unit/credential-name-required-marker.test.ts— keeps the marker string stable across the sentinel + warning + Sage rule (drift would silently break recovery)npm run typecheckcleanNAME_REQUIREDin Sage's reply, set name, re-trigger, certificate finalizesset_my_namewrite-through hitsusers+organization_memberships+ WorkOSRelated
🤖 Generated with Claude Code