Skip to content

Conversation

nikosdouvlis
Copy link
Member

@nikosdouvlis nikosdouvlis commented Sep 1, 2025

Description

errors.global can now be used without checking for the .length property:

if (errors.global) {
   return <div>{errors.global[0].message}</div>
}

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

    • Avoids showing empty generic errors on initial load by treating error lists as absent until needed.
    • Ensures non-API errors display consistently and map reliably to field-specific messages.
    • Prevents rare crashes or UI glitches when processing unexpected error shapes.
  • Refactor

    • Error lists are now created lazily, reducing unnecessary allocations and improving efficiency.

Copy link

changeset-bot bot commented Sep 1, 2025

🦋 Changeset detected

Latest commit: 89b099d

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

This PR includes changesets to release 22 packages
Name Type
@clerk/clerk-js Patch
@clerk/types Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/elements Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/localizations Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/shared Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/themes Patch
@clerk/vue 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

Copy link

vercel bot commented Sep 1, 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 3, 2025 11:04am

Copy link
Contributor

coderabbitai bot commented Sep 1, 2025

Walkthrough

Error handling now treats raw and global error collections as nullable, initializing them to null and creating arrays only when needed. Parsing logic in clerk-js was updated to lazily initialize these arrays. The Errors interface reflects this nullability, and React state proxies now default raw/global to null.

Changes

Cohort / File(s) Summary
Error parsing logic (lazy-init arrays)
packages/clerk-js/src/core/signals.ts
Switched raw/global from always-present arrays to nullable with lazy creation; replaced unconditional pushes with conditional init-and-push logic; removed bulk push(...error.errors) line.
Types: Errors interface nullability
packages/types/src/state.ts
Updated Errors interface: raw and global types changed from unknown[] to `unknown[]
React state defaults
packages/react/src/stateProxy.ts
Updated defaultErrors to initialize raw and global as null instead of empty arrays.
Changeset
.changeset/smart-seas-breathe.md
Bumped patch versions and documented the Errors interface nullability change.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant Parser as parseErrors (clerk-js)
  participant Types as Errors (types)
  participant React as stateProxy

  Caller->>Parser: handle error(e)
  alt Clerk API response (structured)
    Parser->>Types: for each error -> ensure raw/global exist, then push
  else Non-Clerk error (unstructured)
    Parser->>Types: set raw = [e], global = [e] (lazy-init)
  end
  React-->>Caller: defaultErrors (raw=null, global=null)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I nibbled on nulls beneath the moonlit log,
Kept baskets empty until errors jog.
When trouble hops by, I make room with care,
No needless piles — just tidy air.
Thump-thump: lazy lists, a rabbit's flair. 🥕🐇

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch nikos/change-global-errors-type

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

pkg-pr-new bot commented Sep 1, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: 89b099d

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 (3)
packages/types/src/state.ts (1)

25-26: Document new nullability on public API.

Add JSDoc so integrators know to guard with a truthy check instead of .length.

Apply:

 export interface Errors {
   fields: FieldErrors;
-  raw: unknown[] | null;
-  global: unknown[] | null;
+  /** Null when there are no raw errors. Prefer `if (errors.raw)` over checking `.length`. */
+  raw: unknown[] | null;
+  /** Null when there are no global errors. Prefer `if (errors.global)` over checking `.length`. */
+  global: unknown[] | null;
 }
packages/clerk-js/src/core/signals.ts (2)

70-75: Condense lazy initialization and avoid shadowing.

Use nullish-assignment to remove duplication and rename the loop variable to prevent shadowing the outer error.

Apply:

-  error.errors.forEach(error => {
-    if (parsedErrors.raw) {
-      parsedErrors.raw.push(error);
-    } else {
-      parsedErrors.raw = [error];
-    }
+  error.errors.forEach(apiError => {
+    (parsedErrors.raw ??= []).push(apiError);
 
-    if ('meta' in error && error.meta && 'paramName' in error.meta) {
-      const name = snakeToCamel(error.meta.paramName);
-      parsedErrors.fields[name as keyof typeof parsedErrors.fields] = error;
+    if ('meta' in apiError && apiError.meta && 'paramName' in apiError.meta) {
+      const name = snakeToCamel(apiError.meta.paramName);
+      parsedErrors.fields[name as keyof typeof parsedErrors.fields] = apiError;
       return;
     }
 
-    if (parsedErrors.global) {
-      parsedErrors.global.push(error);
-    } else {
-      parsedErrors.global = [error];
-    }
+    (parsedErrors.global ??= []).push(apiError);
   });

Also applies to: 82-86


76-80: Guard unknown param names to avoid writing outside known fields.

If snakeToCamel(paramName) doesn’t match FieldErrors keys, fall back to global.

Apply:

-    if ('meta' in apiError && apiError.meta && 'paramName' in apiError.meta) {
-      const name = snakeToCamel(apiError.meta.paramName);
-      parsedErrors.fields[name as keyof typeof parsedErrors.fields] = apiError;
-      return;
-    }
+    if ('meta' in apiError && apiError.meta && 'paramName' in apiError.meta) {
+      const name = snakeToCamel(apiError.meta.paramName);
+      if (name && (name in parsedErrors.fields)) {
+        parsedErrors.fields[name as keyof typeof parsedErrors.fields] = apiError;
+        return;
+      }
+    }

Also applies to: 82-86

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • 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 a50cfc8 and f2affab.

📒 Files selected for processing (2)
  • packages/clerk-js/src/core/signals.ts (1 hunks)
  • packages/types/src/state.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/clerk-js/src/core/signals.ts
  • packages/types/src/state.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/clerk-js/src/core/signals.ts
  • packages/types/src/state.ts
packages/**/*.{ts,tsx}

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

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/core/signals.ts
  • packages/types/src/state.ts
packages/**/*.{ts,tsx,d.ts}

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

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/core/signals.ts
  • packages/types/src/state.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/clerk-js/src/core/signals.ts
  • packages/types/src/state.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/clerk-js/src/core/signals.ts
  • packages/types/src/state.ts
🧬 Code graph analysis (1)
packages/clerk-js/src/core/signals.ts (1)
packages/shared/src/underscore.ts (1)
  • snakeToCamel (51-53)
⏰ 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). (6)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: semgrep/ci
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
packages/types/src/state.ts (2)

25-26: Change aligns types with runtime (nullable raw/global).

This matches the lazy initialization in clerk-js and enables simple truthy checks by consumers.


25-26: No actionable call‐site changes needed.
Searches for errors.global.length, errors.raw.length, optional‐chained/non‐null‐asserted .length, and direct indexing returned no matches—there are no existing call sites to update.

packages/clerk-js/src/core/signals.ts (2)

55-57: Initialize to null to match updated types.

Correctly mirrors Errors nullability.


64-66: Non-API errors routed to raw/global as singletons.

Good default; avoids empty arrays and keeps semantics consistent.

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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • 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 f2affab and e644e1f.

📒 Files selected for processing (1)
  • .changeset/red-tools-eat.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/**

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

Automated releases must use Changesets.

Files:

  • .changeset/red-tools-eat.md
🪛 LanguageTool
.changeset/red-tools-eat.md

[grammar] ~1-~1: Hier könnte ein Fehler sein.
Context: --- ---

(QB_NEW_DE)

⏰ 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). (23)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (tanstack-react-router, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome)
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (18, --filter=@clerk/astro --filter=@clerk/backend --filter=@clerk/express --filter=@c...
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

Comment on lines 1 to 2
---
---
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Changeset is empty/invalid — specify package bumps and summary.

Without valid frontmatter, CI release won’t pick this up. Given errors.raw/global can now be null at runtime and in types, this is plausibly a breaking change for TS consumers; consider a major bump (or confirm desired semver).

Apply this diff (adjust semver if you decide it’s minor/patch):

---- 
----
+---
+"@clerk/clerk-js": major
+"@clerk/types": major
+---
+
+Make `Errors.raw` and `Errors.global` nullable (`unknown[] | null`) and lazily initialized in clerk-js parsing.
+
+BREAKING (types/runtime): Code assuming arrays must now handle `null`.
+Migration:
+```ts
+if (errors.global) {
+  render(errors.global[0]?.message);
+}
+// or
+for (const e of errors.raw ?? []) { /* ... */ }
+```

🏁 Script executed:

#!/bin/bash

# Inspect the changeset file for missing frontmatter
cat .changeset/red-tools-eat.md

Length of output: 41


Populate .changeset/red-tools-eat.md frontmatter
The file currently contains only empty markers; add valid package bumps and a summary so CI can detect this breaking change. Since errors.raw/errors.global now allow null, this warrants a major bump (or confirm the desired semver).

---- 
----
+---
+"@clerk/clerk-js": major
+"@clerk/types": major
+---
+
+Make `Errors.raw` and `Errors.global` nullable (`unknown[] | null`) and lazily initialized in clerk-js parsing.
+
+BREAKING (types/runtime): Code assuming arrays must now handle `null`.
+Migration:
+```ts
+if (errors.global) {
+  render(errors.global[0]?.message);
+}
+// or
+for (const e of errors.raw ?? []) { /* ... */ }
+```
🧰 Tools
🪛 LanguageTool

[grammar] ~1-~1: Hier könnte ein Fehler sein.
Context: --- ---

(QB_NEW_DE)

🤖 Prompt for AI Agents
In .changeset/red-tools-eat.md around lines 1 to 2, the file contains only empty
markers and needs valid Changeset frontmatter so CI recognizes the release;
replace the empty frontmatter with a YAML block listing the affected package(s)
and their bump type (use "major" because errors.raw/errors.global now accept
null), and add a short summary sentence describing the breaking change (mention
errors.raw/errors.global allowing null and recommended migration notes). Ensure
the file has the standard three-dash delimiters, a "packages:" mapping with the
package names and "major" as the bump, and a non-empty body paragraph explaining
the change.

Copy link
Member

@panteliselef panteliselef left a comment

Choose a reason for hiding this comment

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

Let's verify if an empty changeset is appropriate.

@nikosdouvlis nikosdouvlis requested a review from dstaley September 2, 2025 14:10
@@ -52,30 +52,38 @@ function errorsToParsedErrors(error: unknown): Errors {
captcha: null,
legalAccepted: null,
},
raw: [],
global: [],
raw: null,
Copy link
Member

Choose a reason for hiding this comment

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

I hate that this is the case, but we need to update the default errors in the state proxy in clerk-react as well 😭

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch!
Ill try to prioritize some tests to catch these sooner and a (potential) refactor later. Fixing...

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)
packages/react/src/stateProxy.ts (1)

7-22: Use satisfies Errors to catch drift without widening

Validates the object literal against Errors while keeping precise literal types; future field additions will surface here at compile time.

-const defaultErrors = (): Errors => ({
-  fields: {
-    firstName: null,
-    lastName: null,
-    emailAddress: null,
-    identifier: null,
-    phoneNumber: null,
-    password: null,
-    username: null,
-    code: null,
-    captcha: null,
-    legalAccepted: null,
-  },
-  raw: null,
-  global: null,
-});
+const defaultErrors = (): Errors => {
+  const e = {
+    fields: {
+      firstName: null,
+      lastName: null,
+      emailAddress: null,
+      identifier: null,
+      phoneNumber: null,
+      password: null,
+      username: null,
+      code: null,
+      captcha: null,
+      legalAccepted: null,
+    },
+    raw: null,
+    global: null,
+  } satisfies Errors;
+  return e;
+};
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • 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 e644e1f and 72f1c15.

📒 Files selected for processing (1)
  • packages/react/src/stateProxy.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/react/src/stateProxy.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/react/src/stateProxy.ts
packages/**/*.{ts,tsx}

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

TypeScript is required for all packages

Files:

  • packages/react/src/stateProxy.ts
packages/**/*.{ts,tsx,d.ts}

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

Packages should export TypeScript types alongside runtime code

Files:

  • packages/react/src/stateProxy.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/react/src/stateProxy.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/react/src/stateProxy.ts
⏰ 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). (3)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
packages/react/src/stateProxy.ts (1)

20-21: Confirm no length-based checks on nullable errors
Search across the codebase returned no occurrences of errors.global.length or errors.raw.length, so defaulting these to null aligns with the updated Errors contract. Please manually audit any call sites to ensure none assume these properties are always arrays.

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

🧹 Nitpick comments (1)
.changeset/smart-seas-breathe.md (1)

6-7: Remove stray character and add a succinct migration note.

There’s an orphan “7” rendered in the release notes. Also, consider adding a one‑line migration cue.

-Update the experimental `Errors` interface to allow null for raw and global error arrays
-7
+Update the experimental `Errors` interface to allow null for `raw` and `global` error arrays.
+
+Migration (experimental): check for presence before indexing, e.g.:
+if (errors.global) { render(errors.global[0].message) }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • 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 12c508d and 89b099d.

📒 Files selected for processing (1)
  • .changeset/smart-seas-breathe.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/**

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

Automated releases must use Changesets.

Files:

  • .changeset/smart-seas-breathe.md
⏰ 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). (17)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (tanstack-react-router, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Static analysis
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
.changeset/smart-seas-breathe.md (1)

2-3: Confirm semver level (nullable type can be breaking for TS consumers).

Widening Errors.raw/global to T[] | null may break code that assumed arrays. If the interface is truly experimental and excluded from semver guarantees, patch is fine; otherwise consider minor/major or at least call out “BREAKING (experimental)” in the note.

Comment on lines +1 to +5
---
"@clerk/clerk-js": patch
"@clerk/types": patch
---

Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Changeset likely missing affected React package.

PR modifies packages/react/src/stateProxy.ts but this changeset only bumps @clerk/clerk-js and @clerk/types. If React package code changed, include it here so it’s released together.

Run to verify and catch omissions:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Detect React package name (if present)
react_pkg="$(jq -r '.name' packages/react/package.json 2>/dev/null || true)"

if [[ -n "${react_pkg}" && "${react_pkg}" != "null" ]]; then
  echo "Detected React package: ${react_pkg}"
  # Check if included in any changeset file
  if ! rg -n --fixed-strings --glob '.changeset/*.md' "\"${react_pkg}\":" >/dev/null; then
    echo "ERROR: ${react_pkg} not listed in any changeset file."
    echo "Add a '${react_pkg}: patch' entry to this changeset."
    exit 1
  else
    echo "OK: ${react_pkg} is included in a changeset."
  fi
else
  echo "No packages/react/package.json found; skip."
fi

Length of output: 750


Add missing changeset entry for the React package

packages/react/src/stateProxy.ts was updated, but the changeset .changeset/smart-seas-breathe.md only lists @clerk/clerk-js and @clerk/types. Add

"@clerk/clerk-react": patch

to that file so the React package is released together.

🤖 Prompt for AI Agents
.changeset/smart-seas-breathe.md lines 1-5: the changeset currently only lists
"@clerk/clerk-js" and "@clerk/types" but the React package was changed; update
the file to also include the React package by adding the entry
"\"@clerk/clerk-react\": patch" so the React package is included in the release
alongside the others.

@nikosdouvlis nikosdouvlis merged commit 1b1e8b1 into main Sep 3, 2025
37 checks passed
@nikosdouvlis nikosdouvlis deleted the nikos/change-global-errors-type branch September 3, 2025 12:42
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.

4 participants