Repository navigation
Conversation
|
|
@eli-front is attempting to deploy a commit to the Clerk Production Team on Vercel. A member of the Team first needs to authorize it. |
|
Hello 👋 We currently close PRs after 60 days of inactivity. It's been 50 days since the last update here. If we missed this PR, please reply here. Otherwise, we'll close this PR in 10 days. Thanks for being a part of the Clerk community! 🙏 |
This is still an issue (to prevent stale) |
WalkthroughThis PR introduces a new error code for sign-up restricted waitlist scenarios and refactors error handling across form and routing state machines. Changes normalize error processing patterns, improve safe property access, and systematically add form error clearing before navigation transitions. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (4)
🧰 Additional context used🧬 Code graph analysis (3)packages/elements/src/internals/machines/form/form.machine.ts (1)
packages/elements/src/internals/machines/sign-up/router.machine.ts (3)
packages/elements/src/internals/machines/sign-in/router.machine.ts (3)
⏰ 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). (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@LauraBeatris could you take a look at this? (not sure who would be in charge of elements updates) |
0906b21 to
8c8873d
Compare
|
It looks like there were some significant merge conflicts due to restructuring of clerk elements in #7271. If anyone is having this issue with waitlist signup errors not being handled right (it's still present on diff --git a/dist/chunk-2NFCNVR4.mjs b/dist/chunk-2NFCNVR4.mjs
index cc770c39d5dace71b2c68eda0da00358529aa57b..507976d7a53093849c151cbaa03e45255e8a93d1 100644
--- a/dist/chunk-2NFCNVR4.mjs
+++ b/dist/chunk-2NFCNVR4.mjs
@@ -109,7 +109,10 @@ var FormMachine = setup({
if (isKnownError(event.error)) {
const fields = {};
const globalErrors = [];
- const errors = isClerkAPIResponseError(event.error) ? (_a = event.error) == null ? void 0 : _a.errors : [event.error];
+ const candidate = isClerkAPIResponseError(event.error)
+ ? (event.error?.errors || event.error)
+ : event?.error || [];
+ const errors = Array.isArray(candidate) ? candidate : [candidate];
for (const error of errors) {
const name = isClerkAPIError(error) ? snakeToCamel((_b = error.meta) == null ? void 0 : _b.paramName) : null;
if (!name || isMetamaskError(error)) {
@@ -1716,7 +1719,8 @@ var ERROR_CODES = {
ENTERPRISE_SSO_EMAIL_ADDRESS_DOMAIN_MISMATCH: "enterprise_sso_email_address_domain_mismatch",
ENTERPRISE_SSO_HOSTED_DOMAIN_MISMATCH: "enterprise_sso_hosted_domain_mismatch",
SAML_EMAIL_ADDRESS_DOMAIN_MISMATCH: "saml_email_address_domain_mismatch",
- ORGANIZATION_MEMBERSHIP_QUOTA_EXCEEDED_FOR_SSO: "organization_membership_quota_exceeded_for_sso"
+ ORGANIZATION_MEMBERSHIP_QUOTA_EXCEEDED_FOR_SSO: "organization_membership_quota_exceeded_for_sso",
+ SIGN_UP_RESTRICTED_WAITLIST: 'sign_up_restricted_waitlist',
};
var ROUTING = {
path: "path",
@@ -2934,6 +2938,7 @@ var SignInRouterMachine = setup6({
case ERROR_CODES.ENTERPRISE_SSO_HOSTED_DOMAIN_MISMATCH:
case ERROR_CODES.SAML_EMAIL_ADDRESS_DOMAIN_MISMATCH:
case ERROR_CODES.ORGANIZATION_MEMBERSHIP_QUOTA_EXCEEDED_FOR_SSO:
+ case ERROR_CODES.SIGN_UP_RESTRICTED_WAITLIST:
error = new ClerkElementsError(errorOrig.code, errorOrig.longMessage || "");
break;
default:
@@ -3177,7 +3182,6 @@ var SignInRouterMachine = setup6({
},
Start: {
tags: ["step:start"],
- exit: "clearFormErrors",
invoke: {
id: "start",
src: "startMachine",
@@ -3211,21 +3215,21 @@ var SignInRouterMachine = setup6({
NEXT: [
{
guard: "isComplete",
- actions: "setActive"
+ actions: ["setActive", "clearFormErrors"]
},
{
guard: "statusNeedsFirstFactor",
- actions: { type: "navigateInternal", params: { path: "/continue" } },
+ actions: [{ type: "navigateInternal", params: { path: "/continue" } }, "clearFormErrors"],
target: "FirstFactor"
},
{
guard: "statusNeedsSecondFactor",
- actions: { type: "navigateInternal", params: { path: "/continue" } },
+ actions: [{ type: "navigateInternal", params: { path: "/continue" } }, "clearFormErrors"],
target: "SecondFactor"
},
{
guard: "statusNeedsNewPassword",
- actions: { type: "navigateInternal", params: { path: "/reset-password" } },
+ actions: [{ type: "navigateInternal", params: { path: "/reset-password" } }, "clearFormErrors"],
target: "ResetPassword"
}
] |
…exit to prevent early clear
Description
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Error Iteration Fix
Errors were previously not being parse correctly on the
ERRORS.SETevent causing an issue of "errors not iterable". Thesign_up_restricted_waitlisterror does contain aclerkErrorkey, so it's considered a clerk api response error, but it does not have the plural "errors" in it, but a singular "error".Error Clearing Fix
Currently, when using the clerk elements
<GlobalError />component, it does not correctly handle the state in when a user attempts to sign up when the waitlist only / invite only mode is enabled on clerk. The error gets briefly set in the form state, but the exit condition on the form machine clears the errors before they are rendered to the user.This fix will explicitly switch on this waitlist error code and it will not do a blanket clear of the errors on exit of the start state. This prevents the form from clearing errors prematurely.
Summary by CodeRabbit
New Features
Bug Fixes