Skip to content

feat(deploy): recover from production_instance_exists and surface plan-feature errors#289

Draft
wyattjoh wants to merge 7 commits into
wyattjoh/deployfrom
wyattjoh/deploy-error-recovery
Draft

feat(deploy): recover from production_instance_exists and surface plan-feature errors#289
wyattjoh wants to merge 7 commits into
wyattjoh/deployfrom
wyattjoh/deploy-error-recovery

Conversation

@wyattjoh
Copy link
Copy Markdown
Contributor

@wyattjoh wyattjoh commented May 13, 2026

Summary

Adds two live-error recovery paths in clerk deploy and the small refactors that make them readable. When production-instance creation returns production_instance_exists (HTTP 400) the wizard now refetches the application, persists the existing production instance id, and jumps straight into the reconcile flow as if local state had been intact. When clone validation returns unsupported_subscription_plan_features (HTTP 402) the wizard rethrows a CliError that lists the unsupported features from error.meta.unsupported_features and points at the billing-plans docs.

Details

createProductionInstance is wrapped in a try/catch that branches on the new structured PlapiError.code. On production_instance_exists, reloadProductionState calls fetchApplication, finds the existing production instance, persists its id, and returns an updated DeployContext; the wizard then calls reconcileExistingDeploy and returns, so subsequent runs short-circuit. runValidateCloning is wrapped similarly to translate the plan-features error before any UI is rendered. A small guard rejects production-instance creation responses that come back without active_domain; this required loosening active_domain to nullable in ProductionInstanceResponse so callers must check.

Test plumbing adds two mock injection flags on clerk deploy: --testFailCreateProductionInstanceExists and --testFailValidateCloningUnsupportedFeatures=<feature-list>. The mock layer in commands/deploy/mock.ts produces the corresponding PLAPI error envelopes so the new code paths can be exercised end-to-end without hitting a real Platform API. The deploy README.md gains a "Recovery paths" section documenting both error codes and the wizard's response.

Test plan

  • bun run scripts/run-tests.ts --pattern 'packages/cli-core/src/commands/deploy/**' --concurrency 1
  • bun run typecheck
  • bun run lint
  • CI green

@wyattjoh
Copy link
Copy Markdown
Contributor Author

wyattjoh commented May 13, 2026

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 13, 2026

🦋 Changeset detected

Latest commit: ce49854

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
clerk Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@wyattjoh wyattjoh changed the title wyattjoh/deploy error recovery feat(deploy): recover from production_instance_exists and surface plan-feature errors May 13, 2026
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.

1 participant