Skip to content

fix: show friendly error instead of Zod validation dump when backup status response is unexpected#3702

Open
wojtekn wants to merge 3 commits into
trunkfrom
fix-sync-backup-status-zod-error
Open

fix: show friendly error instead of Zod validation dump when backup status response is unexpected#3702
wojtekn wants to merge 3 commits into
trunkfrom
fix-sync-backup-status-zod-error

Conversation

@wojtekn
Copy link
Copy Markdown
Contributor

@wojtekn wojtekn commented Jun 5, 2026

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.:

[ { "code": "invalid_value", "values": [ "in-progress", "finished", "failed" ], "path": [ "status" ], ... } ]

This happened because syncBackupResponseSchema.parse() throws a ZodError on unexpected input, and ZodError.message is 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. Normal failed status responses from the server are unaffected and continue through the existing pull failure UI path.

Testing Instructions

  • Trigger a pull from a site whose backup status endpoint returns an unexpected response shape (e.g., a WP_Error), or sandbox the API and hardcode error response there
  • Previously: dialog showed raw Zod JSON
  • Now: dialog shows "Unexpected response from server while checking backup status"
  • A valid { status: 'failed', percent: 0, error: '...' } response should show the normal red "Error pulling changes" inline in the UI without a dialog

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

…tatus response is unexpected

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@wojtekn wojtekn requested review from a team and epeicher June 5, 2026 06:59
@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Jun 5, 2026

📊 Performance Test Results

Comparing d3a96be vs trunk

app-size

Metric trunk d3a96be Diff Change
App Size (Mac) 1313.07 MB 1332.82 MB +19.75 MB 🔴 1.5%

site-editor

Metric trunk d3a96be Diff Change
load 1661 ms 1653 ms 8 ms ⚪ 0.0%

site-startup

Metric trunk d3a96be Diff Change
siteCreation 8985 ms 8996 ms +11 ms ⚪ 0.0%
siteStartup 4422 ms 4423 ms +1 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

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.

2 participants