Skip to content

Stop showing automatic passkey sign-in errors to end users - #528

Merged
seanperez29 merged 4 commits into
mainfrom
fix/silent-automatic-passkey-errors
Jul 22, 2026
Merged

Stop showing automatic passkey sign-in errors to end users#528
seanperez29 merged 4 commits into
mainfrom
fix/silent-automatic-passkey-errors

Conversation

@mikepitre

@mikepitre mikepitre commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Two fixes to the automatic passkey sign-in that AuthStartView kicks off when the sign-in form appears.

1. Automatic passkey failures no longer reach end users in release builds

The automatic modal and the AutoFill fallback both start without the user doing anything, so when they fail there's nothing for the person signing in to act on. The error was still being pushed into generalError and presented as a "Whoops, something is wrong" sheet on top of the sign-in form.

The common trigger is an app that hasn't declared a webcredentials: associated domain for its Frontend API. Every attempt fails with Application with identifier <team>.<bundle-id> is not associated with domain <fapi-host>, and only the developer can fix it.

These errors are now presented in debug builds only, so the misconfiguration stays obvious while integrating. Every build still logs through ClerkLogger.

Suppression is limited to ASAuthorizationError, i.e. authorization ceremony failures. Once the user picks a passkey from the AutoFill suggestions or the automatic modal, a server rejection of that credential surfaces as a ClerkAPIError and still presents in every build.

Explicit passkey sign-in (the button in SignInFactorOnePasskeyView) is unchanged and still surfaces errors, since the user initiated it.

2. Automatic passkey sign-in only starts when passkey is a first factor

An instance can enable passkeys for registration and verification while leaving them out of the sign-in factors:

"passkey": {
  "enabled": true,
  "used_for_first_factor": false,
  "first_factors": [],
  "verifications": ["passkey"]
}

passkeySignInIsAvailable checked only enabled, so AuthStartView fired POST /v1/client/sign_ins and prepare_first_factor on every appearance, against an instance that would never accept the assertion. Added passkeyFirstFactorIsEnabled, which mirrors how every other attribute is checked for sign-in, and gated the automatic flow on it.

UserProfileSecurityView keeps using passkeyIsEnabled. Managing passkeys in the profile is separate from whether they're a sign-in factor.

Testing

  • swift build, swift test --skip Integration: 1018 tests pass
  • make format-check, make lint: clean on the changed files
  • New Tests/UI/PasskeyFirstFactorAvailabilityTests.swift covers the four combinations of enabled / used_for_first_factor

The two commits are independent if you'd rather land them separately.

Note

Stop showing automatic passkey sign-in errors to end users in release builds

  • In release builds, passkey authentication failures that occur before user selection (pre-selection) and ASAuthorizationError failures no longer set generalError in AuthStartView, so users don't see confusing automatic passkey prompts fail silently with an error. Debug builds still surface all errors.
  • Adds a passkeyFirstFactorIsEnabled property to Clerk.Environment that returns true only when the passkey attribute is both enabled and marked usedForFirstFactor. The availability check in AuthStartView now uses this instead of the broader passkeyIsEnabled.
  • The new presentAutomaticPasskeyError(_:isPreSelection:) helper in AuthStartView.swift centralizes the conditional error-presentation logic for both autofill and immediate-credential passkey flows.

Macroscope summarized 7506f95.

The automatic passkey modal and the AutoFill fallback both start without
user intent, so a failure has nothing for the person signing in to act on.
An app that has not declared a webcredentials: associated domain for its
Frontend API fails every attempt, which surfaced as a "Whoops, something
is wrong" sheet over the sign-in form. Present these errors in debug
builds only; every build still logs them.
An instance can enable passkeys for registration and verification while
leaving them out of the sign-in factors (enabled: true with
used_for_first_factor: false). AuthStartView checked only the enabled
flag, so it created a passkey sign-in and prepared the first factor on
every appearance of the sign-in form, against an instance that would
never accept the result.
@github-actions

Copy link
Copy Markdown
Contributor

CI paused

CI does not run automatically on pull request updates.

Before merging, manual CI must be run and pass for the latest commit.

When this PR is ready for CI, the PR author or a repository maintainer can comment:

/run ci

Or use the quick action below:

  • Run CI

@mikepitre
mikepitre requested a review from seanperez29 July 22, 2026 20:19
@mikepitre
mikepitre marked this pull request as ready for review July 22, 2026 20:19
@mikepitre

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 54f6f7763c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/ClerkKitUI/Components/Auth/AuthStartView.swift
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds passkeyFirstFactorIsEnabled to Clerk.Environment, based on passkey enablement and first-factor usage. AuthStartView uses this property for passkey sign-in availability and routes automatic passkey failures through conditional error handling. Tests cover enabled, registration-only, disabled, and absent passkey configurations.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: seanperez29

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes one main change in the PR: suppressing automatic passkey sign-in errors for end users.
Description check ✅ Passed The description directly explains both passkey changes and matches the code and tests in the PR.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Tests/UI/PasskeyFirstFactorAvailabilityTests.swift`:
- Around line 41-52: Add a test alongside
passkeyFirstFactorIsDisabledWhenPasskeyIsDisabled that creates an environment
with passkeyEnabled false and usedForFirstFactor false, then asserts both
passkeyIsEnabled and passkeyFirstFactorIsEnabled are false, completing the
enabled/usedForFirstFactor matrix.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7a5c9a25-3644-4c38-b63e-61b952d770f1

📥 Commits

Reviewing files that changed from the base of the PR and between 3b21a53 and 54f6f77.

📒 Files selected for processing (3)
  • Sources/ClerkKitUI/Components/Auth/AuthStartView.swift
  • Sources/ClerkKitUI/Extensions/Environment+Ext.swift
  • Tests/UI/PasskeyFirstFactorAvailabilityTests.swift
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go (manual)
  • clerk/dashboard (manual)
  • clerk/accounts (manual)
  • clerk/backoffice (manual)
  • clerk/clerk (manual)
  • clerk/clerk-docs (manual)
  • clerk/cloudflare-workers (manual)

Comment thread Tests/UI/PasskeyFirstFactorAvailabilityTests.swift
@mikepitre
mikepitre removed the request for review from seanperez29 July 22, 2026 20:23
@mikepitre
mikepitre marked this pull request as draft July 22, 2026 20:23
Comment thread Sources/ClerkKit/Domains/Auth/SignIn/SignIn.swift
The debug-only gate also swallowed attemptFirstFactor failures that occur
after the user selected a credential from the AutoFill suggestions or the
automatic modal, leaving them silently on the sign-in form in release
builds. Suppress only ASAuthorizationError in release: authorization
ceremony failures are the ones that happen without user participation and
are actionable only by the developer, while server rejections of a
selected credential surface as ClerkAPIError and keep presenting.

Also cover the disabled/not-first-factor combination in the environment
tests.
@mikepitre
mikepitre force-pushed the fix/silent-automatic-passkey-errors branch from ea167e2 to d0ef3dd Compare July 22, 2026 20:31
@mikepitre

Copy link
Copy Markdown
Collaborator Author

@codex review

@mikepitre

Copy link
Copy Markdown
Collaborator Author

/run ci

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d0ef3dd613

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/ClerkKitUI/Components/Auth/AuthStartView.swift Outdated
createPasskeySignIn runs the moment the sign-in form appears, before the
credential picker is even requested, so a network or API failure there is
pre-selection by construction and has nothing for the user to act on.
@mikepitre

Copy link
Copy Markdown
Collaborator Author

/run ci

@mikepitre
mikepitre marked this pull request as ready for review July 22, 2026 20:51
@mikepitre
mikepitre requested a review from seanperez29 July 22, 2026 20:51
@seanperez29
seanperez29 merged commit 33a57c3 into main Jul 22, 2026
14 checks passed
@seanperez29
seanperez29 deleted the fix/silent-automatic-passkey-errors branch July 22, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants