fix: show friendly error instead of Zod validation dump when backup status response is unexpected#3702
Open
wojtekn wants to merge 3 commits into
Open
fix: show friendly error instead of Zod validation dump when backup status response is unexpected#3702wojtekn wants to merge 3 commits into
wojtekn wants to merge 3 commits into
Conversation
…tatus response is unexpected Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
📊 Performance Test ResultsComparing d3a96be 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 was used to identify the root cause and implement the fix, with the developer guiding the approach and verifying the fix worked against a real server.
Proposed Changes
When the sync backup status endpoint (GET) returns an unexpected response shape — such as a
WP_Error— Studio was displaying a raw Zod validation error dump in the "Error pulling from <site>" dialog, e.g.:This happened because
syncBackupResponseSchema.parse()throws aZodErroron unexpected input, andZodError.messageis the raw JSON of all validation issues - which ended up verbatim in the user-facing dialog.The fix replaces
.parse()with.safeParse()in both the Desktop pull poller and the CLI pull poller. On validation failure, a friendly translated error message is thrown instead, and the unexpected raw response is logged to the console for debugging. Normalfailedstatus responses from the server are unaffected and continue through the existing pull failure UI path.Testing Instructions
WP_Error), or sandbox the API and hardcode error response there{ status: 'failed', percent: 0, error: '...' }response should show the normal red "Error pulling changes" inline in the UI without a dialogPre-merge Checklist