Skip to content

Conversation

nikosdouvlis
Copy link
Member

@nikosdouvlis nikosdouvlis commented Sep 10, 2025

Description

Fixes the state during the stateProxy -> clerk-js loaded transition (default value -> null -> fapi value)
This is a temporary fix as ideally, we'd like to consolidate the default values of clerk-js with the default values of stateProxy found in clerk-react which will happen in an upcoming PR

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 reliability of authentication flows by ensuring sign-in and sign-up always provide a valid status, preventing rare null/unknown states that could interrupt progress.
    • More consistent UI messaging and handling when requirements or identifiers are missing.
  • Refactor
    • Standardized status values across sign-in and sign-up to be non-null for predictable behavior and smoother user experience.

Copy link

changeset-bot bot commented Sep 10, 2025

⚠️ No Changeset found

Latest commit: fa4a48c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

vercel bot commented Sep 10, 2025

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

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Sep 10, 2025 9:06am

Copy link
Contributor

coderabbitai bot commented Sep 10, 2025

Walkthrough

Status handling was revised to remove nulls and provide explicit fallback strings. SignInFuture and SignUpFuture getters now return concrete statuses when underlying values are falsy. Corresponding type interfaces were updated to make status non-nullable.

Changes

Cohort / File(s) Summary of Changes
SignIn Future status fallback
packages/clerk-js/src/core/resources/SignIn.ts
SignInFuture.status getter now returns `this.resource.status
SignUp Future status fallback
packages/clerk-js/src/core/resources/SignUp.ts
SignUpFuture.status getter now returns `this.resource.status
Types: make status non-nullable
packages/types/src/signInFuture.ts, packages/types/src/signUpFuture.ts
SignInFutureResource.status and SignUpFutureResource.status changed from `...

Sequence Diagram(s)

sequenceDiagram
  actor Caller
  participant SignInFuture
  participant Resource as SignIn Resource

  Caller->>SignInFuture: get status()
  SignInFuture->>Resource: read status
  alt Resource has status
    SignInFuture-->>Caller: SignInStatus
  else status is falsy
    Note over SignInFuture: Fallback applied
    SignInFuture-->>Caller: "needs_identifier"
  end
Loading
sequenceDiagram
  actor Caller
  participant SignUpFuture
  participant Resource as SignUp Resource

  Caller->>SignUpFuture: get status()
  SignUpFuture->>Resource: read status
  alt Resource has status
    SignUpFuture-->>Caller: SignUpStatus
  else status is falsy
    Note over SignUpFuture: Fallback applied
    SignUpFuture-->>Caller: "missing_requirements"
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly describes the primary change of removing the null fallback from the SignIn and SignUp future class status getters and appropriately signals that it’s a fix in the clerk-js package and its type definitions.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Poem

I twitch my ears at statuses clear,
No more nulls to nuzzle in fear.
Sign-in hops to “needs_identifier,” bright,
Sign-up squeaks “missing_requirements” right.
Types are tidy, fields held fast—
A carrot for code that’s built to last. 🥕🐇

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch nikos/fix-null-status

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

Copy link

pkg-pr-new bot commented Sep 10, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: fa4a48c

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: 2

🧹 Nitpick comments (2)
packages/types/src/signInFuture.ts (1)

98-98: Non-nullable status is a TS-facing breaking change; tighten docs.

  • This removes null from the public type, which can break downstream TS consumers relying on null checks. Ensure a release note/semver label reflects this.
  • Clarify in JSDoc that status is never null.

Proposed JSDoc tweak:

- * `'complete'`, etc.)
+ * `'complete'`, etc.). This property is never `null`.
packages/types/src/signUpFuture.ts (1)

53-53: Make the non-null contract explicit; note potential type break.

  • Same as SignIn: this is a breaking type-only change; flag in release notes.
  • Update JSDoc to state it’s never null.

Proposed JSDoc tweak:

- * An array of strings representing unverified fields such as `’email_address’`. Can be used to detect when verification is necessary.
+ * The status is never `null`. Example values: `'missing_requirements'`, `'complete'`, `'abandoned'`.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • 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 acc7699 and fa4a48c.

📒 Files selected for processing (4)
  • packages/clerk-js/src/core/resources/SignIn.ts (1 hunks)
  • packages/clerk-js/src/core/resources/SignUp.ts (1 hunks)
  • packages/types/src/signInFuture.ts (1 hunks)
  • packages/types/src/signUpFuture.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,jsx,ts,tsx}

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

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
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
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/types/src/signInFuture.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignIn.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

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

Use Prettier for consistent code formatting

Files:

  • packages/types/src/signInFuture.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignIn.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
packages/**/*.{ts,tsx}

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

TypeScript is required for all packages

Files:

  • packages/types/src/signInFuture.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignIn.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
packages/**/*.{ts,tsx,d.ts}

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

Packages should export TypeScript types alongside runtime code

Files:

  • packages/types/src/signInFuture.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignIn.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
**/*.{ts,tsx}

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

Use proper TypeScript error types

**/*.{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
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
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/types/src/signInFuture.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignIn.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
**/*.{js,ts,tsx,jsx}

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

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/types/src/signInFuture.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignIn.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
🧬 Code graph analysis (2)
packages/types/src/signInFuture.ts (1)
packages/types/src/signInCommon.ts (1)
  • SignInStatus (61-66)
packages/types/src/signUpFuture.ts (1)
packages/types/src/signUpCommon.ts (1)
  • SignUpStatus (25-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Build Packages
  • GitHub Check: semgrep/ci
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Analyze (javascript-typescript)

Comment on lines 562 to 565
get status() {
return this.resource.status;
// @TODO hooks-revamp: Consolidate this fallback val with stateProxy
return this.resource.status || 'needs_identifier';
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add explicit return type and use nullish coalescing for correctness.

  • Public API: annotate getter return type per guidelines.
  • Prefer ?? over || to avoid unintended fallback on falsy strings (defensive).

Apply:

-  get status() {
-    // @TODO hooks-revamp: Consolidate this fallback val with stateProxy
-    return this.resource.status || 'needs_identifier';
-  }
+  get status(): SignInStatus {
+    // @TODO hooks-revamp: Consolidate this fallback val with stateProxy
+    return this.resource.status ?? 'needs_identifier';
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
get status() {
return this.resource.status;
// @TODO hooks-revamp: Consolidate this fallback val with stateProxy
return this.resource.status || 'needs_identifier';
}
get status(): SignInStatus {
// @TODO hooks-revamp: Consolidate this fallback val with stateProxy
return this.resource.status ?? 'needs_identifier';
}
🤖 Prompt for AI Agents
In packages/clerk-js/src/core/resources/SignIn.ts around lines 562 to 565, the
getter lacks an explicit return type and uses || which can incorrectly fall back
on falsy but valid strings; update the getter signature to include an explicit
return type (e.g., get status(): string or the precise union type used by the
public API) and replace the || fallback with the nullish coalescing operator,
returning this.resource.status ?? 'needs_identifier', ensuring the annotated
return type matches the actual allowed status values.

Comment on lines 542 to 545
get status() {
return this.resource.status;
// @TODO hooks-revamp: Consolidate this fallback val with stateProxy
return this.resource.status || 'missing_requirements';
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Annotate getter return type and use ?? for the fallback.

  • Add explicit return type to the public getter.
  • Use nullish coalescing for robustness.

Apply:

-  get status() {
-    // @TODO hooks-revamp: Consolidate this fallback val with stateProxy
-    return this.resource.status || 'missing_requirements';
-  }
+  get status(): SignUpStatus {
+    // @TODO hooks-revamp: Consolidate this fallback val with stateProxy
+    return this.resource.status ?? 'missing_requirements';
+  }
🤖 Prompt for AI Agents
In packages/clerk-js/src/core/resources/SignUp.ts around lines 542 to 545, the
public getter lacks an explicit return type and uses || for fallback; change the
signature to include an explicit return type (e.g., string or the appropriate
union type used elsewhere) and replace the logical OR with nullish coalescing so
the getter returns this.resource.status ?? 'missing_requirements'.

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