Always send an admin password so a renamed admin user can't block site startup - #4821
Merged
Merged
Conversation
…e startup Changing a site's admin username without a stored password left the site unable to start: the admin API was asked to create the new user with no password and returned an error, killing the server process. The default now lives in @studio/common and is sent to the CLI rather than only shown in the settings field. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Collaborator
📊 Performance Test ResultsComparing 1e5fe59 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues
How AI was used in this PR
Claude Code investigated the failure from a real broken site, traced it to the admin-credentials request builder, wrote the fix and the regression test, and verified it end-to-end by rebuilding the CLI and starting the affected site.
Proposed Changes
Changing a site's admin username in Settings — without also setting a password — left the site unable to start. Every start attempt failed with
Failed to set admin credentials: Password is required to create a new admin user, and the server process was killed.The cause was an inconsistent treatment of "no stored password" across the codebase. The settings screen displayed
passwordas a default in the field, but that value was never persisted, and the startup path omitted the password from its request entirely when none was stored. WordPress can update an existing user without a password, but it cannot create one — so as soon as the username named a user that didn't exist yet, startup failed outright.This makes the default a real value rather than field decoration: it now lives in
@studio/commonas a single source of truth and is actually sent to the CLI. A site in this state starts normally again and the renamed admin user is created, with the original user left intact (existing behavior). No action is needed from users whose sites already work.Two related inconsistencies are fixed along the way:
apps/localcompared an unset password against''while the desktop compared against the encoded default, so a settings save could behave differently in the browser UI than in the desktop app.Known gap, not addressed here: when startup fails this way, Studio misreports it as a PHP error —
isPhpUserError()treats any non-infrastructure error as user PHP, andparsePhpError()finds nothing quotable in a Node stack trace, so the user sees a bare "PHP error during startup" page and a file watcher waiting for a.phpedit that can never fix it. That misclassification is what made this bug hard to diagnose, and is worth a follow-up.Testing Instructions
Reproducing on trunk:
admine) and save without touching the password field.~/.studio/daemon/logs/studio-site-<siteId>-error-*.log:Password is required to create a new admin user.With this branch, step 2 starts normally and the new admin user is created.
Also worth checking:
npm run cli:build:ui && node apps/cli/dist/cli/main.mjs ui --no-open), since both front ends are touched.Pre-merge Checklist
🤖 Generated with Claude Code