feat(deploy): recover from production_instance_exists and surface plan-feature errors#289
Draft
wyattjoh wants to merge 7 commits into
Draft
feat(deploy): recover from production_instance_exists and surface plan-feature errors#289wyattjoh wants to merge 7 commits into
wyattjoh wants to merge 7 commits into
Conversation
…ures When validateCloning returns HTTP 402 with code unsupported_subscription_plan_features, rethrow a CliError whose message lists the unsupported features from meta.unsupported_features and includes a docs URL hint pointing at clerk.com/docs/billing/plans.
This was referenced May 13, 2026
Contributor
Author
|
Stack: api-errors-and-deploy Part of a stacked PR chain. Do not merge manually. |
🦋 Changeset detectedLatest commit: ce49854 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
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.
Summary
Adds two live-error recovery paths in
clerk deployand the small refactors that make them readable. When production-instance creation returnsproduction_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 returnsunsupported_subscription_plan_features(HTTP 402) the wizard rethrows aCliErrorthat lists the unsupported features fromerror.meta.unsupported_featuresand points at the billing-plans docs.Details
createProductionInstanceis wrapped in a try/catch that branches on the new structuredPlapiError.code. Onproduction_instance_exists,reloadProductionStatecallsfetchApplication, finds the existing production instance, persists its id, and returns an updatedDeployContext; the wizard then callsreconcileExistingDeployand returns, so subsequent runs short-circuit.runValidateCloningis wrapped similarly to translate the plan-features error before any UI is rendered. A small guard rejects production-instance creation responses that come back withoutactive_domain; this required looseningactive_domainto nullable inProductionInstanceResponseso callers must check.Test plumbing adds two mock injection flags on
clerk deploy:--testFailCreateProductionInstanceExistsand--testFailValidateCloningUnsupportedFeatures=<feature-list>. The mock layer incommands/deploy/mock.tsproduces the corresponding PLAPI error envelopes so the new code paths can be exercised end-to-end without hitting a real Platform API. The deployREADME.mdgains 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 1bun run typecheckbun run lint