-
Notifications
You must be signed in to change notification settings - Fork 358
fix(clerk-js): Do not allow setActive({ organization: null })
when organization selection is forced
#6073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 19999c2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
aa47320
to
b24bfad
Compare
b24bfad
to
4a473d9
Compare
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
4a473d9
to
c6cf838
Compare
c6cf838
to
5dd6089
Compare
📝 WalkthroughWalkthroughA validation check was added to the Changes
Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes were found. Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Error: Server ErrorThe server encountered a temporary error and could not complete your request.Please try again in 30 seconds. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (25)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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/clerk-js/src/core/clerk.ts (1)
1074-1076
: Consider using ClerkRuntimeError for consistency.The validation logic is correct and well-placed. However, for consistency with other error handling in this file, consider using
ClerkRuntimeError
instead of a genericError
.- if (organization === null && this.environment?.organizationSettings?.forceOrganizationSelection) { - throw new Error('setActive requires an organization parameter when organization selection is forced.'); - } + if (organization === null && this.environment?.organizationSettings?.forceOrganizationSelection) { + throw new ClerkRuntimeError('setActive requires an organization parameter when organization selection is forced.'); + }This would align with the error handling patterns used elsewhere in the codebase.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.changeset/petite-ravens-see.md
(1 hunks)packages/clerk-js/src/core/clerk.ts
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/clerk-js/src/core/clerk.ts (1)
packages/react/src/isomorphicClerk.ts (1)
organization
(658-664)
🔇 Additional comments (2)
packages/clerk-js/src/core/clerk.ts (1)
1061-1183
: Validation guard implementation looks solid.The placement and logic of the organization validation check is excellent:
- Early placement ensures fail-fast behavior
- Proper use of optional chaining to handle undefined environment
- Clear and descriptive error message
- Correctly targets only explicit
null
values, notundefined
The implementation effectively prevents invalid state transitions when organization selection is mandatory.
.changeset/petite-ravens-see.md (1)
1-6
: Changeset documentation is accurate and well-formatted.The changeset correctly documents this as a patch-level change and provides a clear description of the functionality being added.
5dd6089
to
dee8e62
Compare
Description
Resolves ORGS-682
Disclaimer: We're also going to apply protections on the API side, this is just an additional guard.
Introduces an error guard not to allow calling
setActive({ organization: null })
when organization selection is forced on the instance settings.The same handling should be made when we refactor
setActive
tosetCurrent
👀Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit