fix: show error messages in god-mode instance setup form#8974
fix: show error messages in god-mode instance setup form#8974chkn wants to merge 1 commit intomakeplane:previewfrom
Conversation
The setup form's local EErrorCodes enum used string values like "INSTANCE_NOT_CONFIGURED" but the backend sends numeric error codes (e.g. 5155). The switch statement never matched, silently swallowing all errors and leaving the user staring at the same form with no feedback. Aligns the setup form with the sign-in form's working pattern: authErrorHandler + AuthBanner. Also adds INSTANCE_NOT_CONFIGURED and PASSWORD_TOO_WEAK to EAdminAuthErrorCodes, which were missing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe pull request adds two new admin authentication error codes ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/admin/components/instance/setup-form.tsx (1)
54-85:⚠️ Potential issue | 🟠 MajorTelemetry opt-out from query params can’t be applied.
is_telemetry_enabled=Falsegets parsed tofalseat Line 54, but Line 84 only updates form state when the value is truthy. That leaves telemetry enabled (true) even when the URL explicitly saysFalse.💡 Proposed fix
- const isTelemetryEnabledParam = searchParams?.get("is_telemetry_enabled") === "True"; + const isTelemetryEnabledParam = searchParams?.get("is_telemetry_enabled"); @@ - if (isTelemetryEnabledParam) setFormData((prev) => ({ ...prev, is_telemetry_enabled: isTelemetryEnabledParam })); + if (isTelemetryEnabledParam !== null) + setFormData((prev) => ({ ...prev, is_telemetry_enabled: isTelemetryEnabledParam === "True" }));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/admin/components/instance/setup-form.tsx` around lines 54 - 85, is_telemetry_enabled from query params is turned into a boolean at declaration so the effect's truthy check skips explicit "False"; change the parsing to capture the raw string and apply the boolean conversion only when the param exists: replace the current isTelemetryEnabledParam with a raw value (e.g. isTelemetryEnabledParamRaw = searchParams?.get("is_telemetry_enabled")), then in the useEffect for initializing formData check if isTelemetryEnabledParamRaw !== null/undefined and call setFormData(prev => ({ ...prev, is_telemetry_enabled: isTelemetryEnabledParamRaw === "True" })); update any references from isTelemetryEnabledParam to the new raw variable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/admin/components/instance/setup-form.tsx`:
- Around line 87-92: The useEffect watching errorCode only sets errorInfo when
authErrorHandler(errorCode) returns a detail, but it never clears stale state;
update the effect in setup-form.tsx so that inside the effect you call
authErrorHandler(errorCode as EAdminAuthErrorCodes) and if it returns a detail
setErrorInfo(detail), otherwise call setErrorInfo(undefined) (also handle the
case when errorCode is falsy by clearing via setErrorInfo(undefined)),
referencing the existing useEffect, errorCode, authErrorHandler, and
setErrorInfo symbols to locate and change the logic.
---
Outside diff comments:
In `@apps/admin/components/instance/setup-form.tsx`:
- Around line 54-85: is_telemetry_enabled from query params is turned into a
boolean at declaration so the effect's truthy check skips explicit "False";
change the parsing to capture the raw string and apply the boolean conversion
only when the param exists: replace the current isTelemetryEnabledParam with a
raw value (e.g. isTelemetryEnabledParamRaw =
searchParams?.get("is_telemetry_enabled")), then in the useEffect for
initializing formData check if isTelemetryEnabledParamRaw !== null/undefined and
call setFormData(prev => ({ ...prev, is_telemetry_enabled:
isTelemetryEnabledParamRaw === "True" })); update any references from
isTelemetryEnabledParam to the new raw variable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6f000675-0a55-4ca4-ac17-ac1f99442d12
📒 Files selected for processing (3)
apps/admin/app/(all)/(home)/auth-helpers.tsxapps/admin/components/instance/setup-form.tsxpackages/constants/src/auth/index.ts
| useEffect(() => { | ||
| if (errorCode) { | ||
| const errorDetail = authErrorHandler(errorCode as EAdminAuthErrorCodes); | ||
| if (errorDetail) setErrorInfo(errorDetail); | ||
| } | ||
| }, [errorCode]); |
There was a problem hiding this comment.
Clear stale banner state when error_code is absent or unrecognized.
Current logic only sets state on recognized codes; it does not reset previous errors when error_code is removed/changed. That can leave an outdated banner visible.
💡 Proposed fix
useEffect(() => {
- if (errorCode) {
- const errorDetail = authErrorHandler(errorCode as EAdminAuthErrorCodes);
- if (errorDetail) setErrorInfo(errorDetail);
- }
+ setErrorInfo(errorCode ? authErrorHandler(errorCode as EAdminAuthErrorCodes) : undefined);
}, [errorCode]);📝 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.
| useEffect(() => { | |
| if (errorCode) { | |
| const errorDetail = authErrorHandler(errorCode as EAdminAuthErrorCodes); | |
| if (errorDetail) setErrorInfo(errorDetail); | |
| } | |
| }, [errorCode]); | |
| useEffect(() => { | |
| setErrorInfo(errorCode ? authErrorHandler(errorCode as EAdminAuthErrorCodes) : undefined); | |
| }, [errorCode]); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/admin/components/instance/setup-form.tsx` around lines 87 - 92, The
useEffect watching errorCode only sets errorInfo when
authErrorHandler(errorCode) returns a detail, but it never clears stale state;
update the effect in setup-form.tsx so that inside the effect you call
authErrorHandler(errorCode as EAdminAuthErrorCodes) and if it returns a detail
setErrorInfo(detail), otherwise call setErrorInfo(undefined) (also handle the
case when errorCode is falsy by clearing via setErrorInfo(undefined)),
referencing the existing useEffect, errorCode, authErrorHandler, and
setErrorInfo symbols to locate and change the logic.
Summary
/god-mode/instance setup form silently swallowed all backend errors, leaving users staring at the same form with query params in the URL but no visible messageEErrorCodesenum used readable string values ("INSTANCE_NOT_CONFIGURED","INVALID_EMAIL", etc.) but the backend sends numeric error codes (5155,5160, etc.) — the switch statement never matchedauthErrorHandler+AuthBanner) — the setup form is now aligned with itINSTANCE_NOT_CONFIGURED(5000) andPASSWORD_TOO_WEAK(5021) toEAdminAuthErrorCodes, which were missing despite being sent by the admin sign-up endpointFiles changed
packages/constants/src/auth/index.ts— addINSTANCE_NOT_CONFIGUREDandPASSWORD_TOO_WEAKtoEAdminAuthErrorCodesapps/admin/app/(all)/(home)/auth-helpers.tsx— add messages and banner handling for those two codesapps/admin/components/instance/setup-form.tsx— replace broken switch-based error logic withauthErrorHandler+AuthBannerTest plan
/god-mode/on a fresh instance (setup not done)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes