Skip to content

fix(migrations): show retry failure over stale precheck error in PrecheckPanel - #14313

Closed
detail-app[bot] wants to merge 1 commit into
mainfrom
detail/bug-fix/fix-migrations-show-retry-failure-over-stale-prech-227d1e
Closed

detail-app[bot] wants to merge 1 commit into
mainfrom
detail/bug-fix/fix-migrations-show-retry-failure-over-stale-prech-227d1e

Conversation

@detail-app

@detail-app detail-app Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Summary

Related Issue: polarsource/feedback#485

On the merchant-migration source_setup step, PrecheckPanel showed the stale prior-run error instead of a just-failed retry's own failure message. The fix reorders the error derivation so the newest failure wins.

What

  • PrecheckPanel.tsx: the error ternary now checks precheck.isError first, then the cached operation.error (with a new generic fallback for a failed operation lacking an error string), then null.
  • PrecheckPanel.test.tsx (new): the first component-test harness for this panel, covering the ordering invariant and the sticky-error-clearing behavior.

Why

A failed retry POST does not overwrite the cached migration.operation — the useRunMerchantMigrationPrecheck mutation only writes query data in onSuccess. So when a prior worker precheck left operation.status === 'failed' with a non-empty operation.error, the old derivation (failed ? operation.error : null) || (precheck.isError ? retryMsg : null) short-circuited on the cached value, and the precheck.isError branch was dead. After a failed retry the merchant saw the same stale "We couldn't verify the Stripe key right now…" text instead of "We couldn't start the pre-check. Please try again." — an attribution gap (the corrective action is identical either way). Introduced when PR #14253 rewrote the panel from sync to async polling.

How

One-line operand reorder so the newest failure takes precedence, mirroring the sibling ReviewTable's ordering. Added a generic fallback ("We couldn't run the pre-check. Please try again.") for the defensive case where a failed operation has no error string. No new imports, types, or behavioral contracts.

Testing

  • New PrecheckPanel component suite (6 tests): mocks api.POST to drive the real useRunMerchantMigrationPrecheck mutation through a real QueryClient (shared with the mocked getQueryClient so onSuccess cache writes are observable) and stubs Orbit components. Covers: stale error shown when idle, retry failure wins over stale (the bug), retry failure with no prior run, failed-without-error fallback, in-flight spinner/disabled state, and no-sticky-error after a successful retry.
  • Red/green confirmed: with the buggy derivation swapped back, 4 tests fail (stale text shadows the retry error); with the fix, all 6 pass.
  • Routine checks pass: web unit suite (408 tests), tsc --noEmit, type-aware oxlint, and oxfmt --check on the changed files.
  • End-to-end against the live local stack was not run: the dev docker stack couldn't initialize — the host filesystem (a 20GB loop device) was 100% full, so the per-instance Postgres database and MinIO buckets couldn't be created (No space left on device during CREATE DATABASE / MinIO setup). The behavior it would verify (the rendered error-text swap) is otherwise covered by the real-mutation component suite above.

Checklist

  • This PR addresses a single concern (one bug fix)
  • The diff is reasonably sized and easy to review
  • New functionality is covered by tests
  • Linting and type checking pass
  • No unrelated changes or drive-by fixes are included

Automatic Fixes PRs can be configured here.

Review in cubic

@detail-app
detail-app Bot requested a review from psincraian September 9, 2026 16:09
@vercel

vercel Bot commented Sep 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
orbit Ready Ready Preview Sep 9, 2026 4:13pm UTC
polar-test Ready Ready Preview Sep 9, 2026 4:13pm UTC

Request Review

This branch was successfully deployed

2 active deployments
Preview – polar-test 8247dca5 Deployed Sep 9, 2026 by vercel[bot]
Preview – orbit 8247dca5 Deployed Sep 9, 2026 by vercel[bot]
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