Skip to content

Conversation

@kduprey
Copy link
Member

@kduprey kduprey commented Dec 17, 2025

Description

Currently, if a C2 starts to add their Web3 wallet, but rejects the request to sign the message (e.g. closes the browser window pop up to sign the message), the identifier is still added but marked unverified and still allows users to "Set primary" identifier, which results in a 422 error.

This hides this option from the action menu and only lets the user remove the Web3 connection from their account in order to request to add the connection again and complete the full verification flow.

USER-4238

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

Bug Fixes

  • Improved error handling and messaging for Web3 wallet connections in the user profile, providing clearer feedback when connection issues occur.
  • Enhanced verification status management for Web3 wallets to ensure appropriate options are displayed based on verification state.

✏️ Tip: You can customize this high-level summary in your review settings.

…ed_at to PasswordSection test fixtures

Signed-off-by: Kenton Duprey <[email protected]>
@kduprey kduprey requested a review from dstaley December 17, 2025 01:02
@kduprey kduprey self-assigned this Dec 17, 2025
@changeset-bot
Copy link

changeset-bot bot commented Dec 17, 2025

🦋 Changeset detected

Latest commit: 06dff03

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Dec 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Dec 17, 2025 10:39pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This PR addresses a Web3 wallet connection issue by preventing users from setting unverified wallets as primary. Changes include modifying the Web3WalletMenu component to accept an isVerified parameter and conditionally render the "Set primary" action only for verified wallets, plus consolidating error handling in Web3Form to use a centralized error handler. Test fixtures are extended with additional fields.

Changes

Cohort / File(s) Summary
Web3 Action Menu Verification
packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx
Modified Web3WalletMenu signature to accept isVerified boolean parameter; conditionally includes the nonPrimary action only when wallet is verified.
Web3 Error Handling
packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx
Consolidated error handling from two-step local parsing (getFieldError + handleError) to centralized web3CallbackErrorHandler(err, card.setError); removed Text component import and usage for error display.
Test Fixtures
packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
Extended test data fixtures with additional fields (enterprise_connection_id, last_authenticated_at) in enterprise_account/verification blocks.
Release Documentation
.changeset/busy-frogs-type.md
Added changeset declaring minor version bump for @clerk/clerk-js documenting Web3 connection error handling fix.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10-15 minutes

  • Verify that web3CallbackErrorHandler in Web3Form properly handles all error cases previously managed by the two-step parsing approach
  • Confirm the isVerified parameter derivation (wallet.verification.status === 'verified') correctly identifies verified wallets for conditional action rendering

Poem

🐰 Web3 wallets hopping true,
Only verified ones will do—
No primary before proof,
Errors handled, staying aloof!
Rabbit's wisdom: verify first! 🌟

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: error handling improvements and Web3WalletMenu verification status logic adjustments.
Linked Issues check ✅ Passed The PR implementation meets all requirements: Web3WalletMenu now accepts isVerified parameter, conditionally hides 'Set primary' for unverified wallets, and fixes error handling to prevent 422 errors.
Out of Scope Changes check ✅ Passed The changeset and code modifications are fully aligned with the PR objectives. The test data augmentation in PasswordSection.test.tsx appears ancillary but not out-of-scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 17, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7489

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@7489

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@7489

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@7489

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@7489

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7489

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7489

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@7489

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@7489

@clerk/express

npm i https://pkg.pr.new/@clerk/express@7489

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@7489

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@7489

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@7489

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@7489

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@7489

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@7489

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7489

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@7489

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@7489

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@7489

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7489

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7489

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@7489

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@7489

commit: 06dff03

@kduprey kduprey changed the title fix(web3): Update error handling and adjust Web3WalletMenu logic with verification status fix(clerk-js): Update error handling and adjust Web3WalletMenu logic with verification status Dec 17, 2025
@kduprey
Copy link
Member Author

kduprey commented Dec 17, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.changeset/busy-frogs-type.md (1)

2-2: Consider using 'patch' instead of 'minor' for this bug fix.

This PR fixes a bug (preventing the 422 error when attempting to set an unverified Web3 wallet as primary), which typically warrants a patch version bump rather than a minor version bump. According to semantic versioning, minor versions are for new features, while patches are for bug fixes.

Apply this diff if you agree:

-'@clerk/clerk-js': minor
+'@clerk/clerk-js': patch
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 54cd476 and 4778123.

📒 Files selected for processing (4)
  • .changeset/busy-frogs-type.md (1 hunks)
  • packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx (2 hunks)
  • packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx (3 hunks)
  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx (8 hunks)
🧰 Additional context used
📓 Path-based instructions (18)
packages/clerk-js/src/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)

packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should be written in camelCase
Use useCardState for card-level state management
Use useFormState for form-level state management
Use useLoadingStatus for managing loading states
Use useFormControl hook for form field state management with validation and localization support
All rendered values must be localized using useLocalizations hook - hard coded values are not allowed
Use localizationKeys for translating UI text with support for parameters and error messages
Use handleError utility for API error handling and provide field states for proper error mapping
Use the styled system sx prop with theme tokens for custom styling instead of inline styles
Use the Card component pattern with Card.Root, Card.Header, Card.Title, Card.Content, and Card.Footer for consistent card layouts
Use FormContainer with headerTitle and headerSubtitle localization keys combined with Form.Root and FormButtons for consistent form layouts
When form submission occurs, manage loading and error states by calling status.setLoading(), card.setLoading(), and card.setError() appropriately

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

All code must pass ESLint checks with the project's configuration

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx
packages/**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Follow established naming conventions (PascalCase for components, camelCase for variables)

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx
packages/**/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{test,spec}.{ts,tsx,js,jsx}: Unit tests are required for all new functionality
Verify proper error handling and edge cases
Include tests for all new features

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
**/*.ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.tsx: Use error boundaries in React components
Minimize re-renders in React components

**/*.tsx: Use proper type definitions for props and state in React components
Leverage TypeScript's type inference where possible in React components
Use proper event types for handlers in React components
Implement proper generic types for reusable React components
Use proper type guards for conditional rendering in React components

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx
**/*.{test,spec,e2e}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use real Clerk instances for integration tests

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
**/*.{md,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Update documentation for API changes

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx
**/*.test.tsx

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use React Testing Library for component testing

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
**/*.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components (e.g., UserProfile, NavigationMenu)
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Separate UI components from business logic components
Use useState for simple state management in React components
Use useReducer for complex state logic in React components
Implement proper state initialization in React components
Use proper state updates with callbacks in React components
Implement proper state cleanup in React components
Use Context API for theme/authentication state management
Implement proper state persistence in React applications
Use React.memo for expensive components
Implement proper useCallback for handlers in React components
Use proper useMemo for expensive computations in React components
Implement proper virtualization for lists in React components
Use proper code splitting with React.lazy in React applications
Implement proper cleanup in useEffect hooks
Use proper refs for DOM access in React components
Implement proper event listener cleanup in React components
Use proper abort controllers for fetch in React components
Implement proper subscription cleanup in React components
Use proper HTML elements for semantic HTML in React components
Implement proper ARIA attributes for accessibility in React components
Use proper heading hierarchy in React components
Implement proper form labels in React components
Use proper button types in React components
Implement proper focus management for keyboard navigation in React components
Use proper keyboard shortcuts in React components
Implement proper tab order in React components
Use proper ...

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx
**/*.{test,spec}.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.{test,spec}.{jsx,tsx}: Use React Testing Library for unit testing React components
Test component behavior, not implementation details
Use proper test queries in React Testing Library tests
Implement proper test isolation in React component tests
Use proper test coverage in React component tests
Test component interactions in integration tests
Use proper test data in React component tests
Implement proper test setup in React component tests
Use proper test cleanup in React component tests
Implement proper test assertions in React component tests
Use proper test structure for React component tests

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Implement type guards for unknown types using the pattern function isType(value: unknown): value is Type
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details in classes
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like <T extends { id: string }>
Use utility types like Omit, Partial, and Pick for data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @param, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Use const assertions with as const for literal types
Use satisfies operator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Use React Testing Library for component testing

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Use ESLint with custom configurations tailored for different package types

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx
**/*.{js,ts,jsx,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Use Prettier for code formatting across all packages

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx
  • packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx
🧬 Code graph analysis (1)
packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx (1)
packages/clerk-js/src/ui/utils/web3CallbackErrorHandler.ts (1)
  • web3CallbackErrorHandler (10-23)
🔇 Additional comments (6)
packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx (1)

142-142: LGTM: Test fixtures enhanced with additional enterprise fields.

The test data has been augmented with enterprise_connection_id and last_authenticated_at fields, making the fixtures more complete and aligned with the actual data structure. These additions improve test data quality without affecting test logic.

Also applies to: 159-160, 218-218, 235-236, 387-387, 404-405, 464-464, 481-482

packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx (2)

9-9: LGTM: Centralized error handling improves consistency.

The refactor to use web3CallbackErrorHandler consolidates error handling logic and provides better error messages for Web3-specific failures (e.g., missing wallet extensions). This aligns with the coding guideline to use the handleError utility for proper error mapping.

Also applies to: 63-63


12-12: Error display is properly handled via Card.Alert in Web3Section.

The Text component removal from Web3Form.tsx imports has no impact on error handling. The AddWeb3WalletActionMenu component calls card.setError() via web3CallbackErrorHandler (line 63), and since both AddWeb3WalletActionMenu and Web3Section share the same card state context, errors display correctly through <Card.Alert>{card.error}</Card.Alert> in Web3Section (line 56).

packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx (3)

98-101: LGTM: Correctly passes verification status to menu.

The Web3WalletMenu now receives the isVerified prop computed from wallet.verification.status === 'verified', enabling the menu to conditionally render actions based on verification state.


121-149: LGTM: Fix properly prevents setting unverified wallets as primary.

The updated logic correctly addresses the bug by gating the "Set primary" action with the isVerified condition. This prevents users from attempting to set an unverified Web3 wallet as primary, which would result in a 422 error. The comment on line 132 clearly documents the intention.

The implementation properly:

  • Updates the function signature to accept isVerified
  • Adds the verification check to the conditional rendering
  • Filters null actions from the array
  • Maintains the "Remove" action for all wallets (verified or not)

100-100: The type safety is correct. wallet.verification.status is properly typed as VerificationStatus | null, where VerificationStatus is the union 'unverified' | 'verified' | 'transferable' | 'failed' | 'expired'. The equality check wallet.verification.status === 'verified' correctly returns true only for the 'verified' state and treats all other states (including null) as unverified. No changes needed.

Signed-off-by: Kenton Duprey <[email protected]>
@kduprey kduprey force-pushed the kenton/user-4238-fix-userprofile-web3walletmenu-actions-to-remove-set-primary branch from 4778123 to 7f31ffd Compare December 17, 2025 18:38
@kduprey kduprey enabled auto-merge (squash) December 17, 2025 22:38
@kduprey kduprey merged commit 4bcc8b6 into release/core-2 Dec 17, 2025
44 checks passed
@kduprey kduprey deleted the kenton/user-4238-fix-userprofile-web3walletmenu-actions-to-remove-set-primary branch December 17, 2025 22:46
kduprey added a commit that referenced this pull request Dec 18, 2025
…with verification status (#7489)

Signed-off-by: Kenton Duprey <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants