Skip to content

fix(admin): surface API validation errors on instance setup form - #10285

Closed
CoderSufiyan wants to merge 1 commit into
makeplane:previewfrom
CoderSufiyan:fix/instance-setup-api-validation-errors
Closed

CoderSufiyan wants to merge 1 commit into
makeplane:previewfrom
CoderSufiyan:fix/instance-setup-api-validation-errors

Conversation

@CoderSufiyan

@CoderSufiyan CoderSufiyan commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #10283. The instance setup form (/god-mode/) never displayed validation errors returned by the API.

Root cause

When setup fails, the API redirects back with:

/god-mode/?error_code=5160&error_message=INVALID_ADMIN_EMAIL&...

error_code is the numeric authentication error code (see AUTHENTICATION_ERROR_CODES in apps/api/plane/authentication/adapter/error.py), while error_message is the machine-readable constant.

The form had a local EErrorCodes enum with string values and switched on errorCode against them:

  • errorCode is "5160", but the enum values were "INVALID_EMAIL", "USER_ALREADY_EXISTS", etc. — they can never match.
  • Several names also did not match the backend constants (INVALID_EMAIL vs INVALID_ADMIN_EMAIL, USER_ALREADY_EXISTS vs ADMIN_USER_ALREADY_EXIST).

So errorData always resolved to { type: undefined } and nothing was rendered.

Changes

  • Replaced the local enum with the shared EAuthErrorCodes from @plane/constants, whose values are the numeric codes the API actually sends. This is the same enum the admin sign-in flow already uses.
  • Match the incoming error_code against that enum instead of against mismatched string names.
  • Added user-facing messages for the codes the setup endpoint can return, instead of surfacing the raw constant (e.g. INVALID_ADMIN_EMAIL).
  • Kept the existing UX: INVALID_ADMIN_EMAIL renders inline on the email field, INVALID_ADMIN_PASSWORD / PASSWORD_TOO_WEAK render inline on the password field, and everything else renders in the banner. Unknown codes now fall back to the API's error_message in the banner instead of being silently dropped.

Testing

Ran in apps/admin (after pnpm turbo run build --filter="./packages/*" so workspace packages resolve):

  • pnpm --filter=admin check:types — passes (only pre-existing Vite config warnings)
  • pnpm --filter=admin check:lint — 0 errors (15 pre-existing warnings, under the configured limit)
  • pnpm --filter=admin check:format — clean

No backend changes required; the API already sends both parameters.

Reviewer notes

  • error_message contains a machine-readable constant rather than prose, so I map known codes to readable copy. If you'd prefer to keep the raw value or move these strings into @plane/i18n, happy to adjust.

Summary by CodeRabbit

  • Bug Fixes
    • Authentication setup errors now display in the relevant email or password field when possible.
    • Other errors appear in a banner, including messages returned for unrecognized error codes. Error messages can also be shown when only a code or message is available.

@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The instance setup form now parses API error codes and messages independently. It maps selected codes to user-facing messages, displays applicable errors on email and password fields, and shows other available messages in a banner.

Changes: Instance setup error display

Layer / File(s) Summary
Shared error codes and parsing
apps/admin/components/instance/setup-form.tsx
The form uses shared authentication error codes and maps selected codes to messages. It falls back to the API message when no mapped message is available.
Banner and inline field errors
apps/admin/components/instance/setup-form.tsx
The banner displays messages unless the error is assigned to an inline field. The email field handles invalid-email errors, and the password field handles invalid-password and weak-password errors.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: Minimal · up to 5ba90

This change makes the instance setup form show API validation errors inline or in a banner. No concrete merge-blocking risk was found, and the change is limited to one admin form component.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@CoderSufiyan

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate of #10284, which fixes the same issue (#10283) in the same file and was opened earlier. I missed the existing PR when checking before starting — sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: Instance setup form does not display validation errors from the API

1 participant