Skip to content

feat(apps): reclaim a deleted app ID from bl apps create - #49

Merged
scottcrawford03 merged 2 commits into
block:mainfrom
nandiheath:nandi/reclaim-deleted-app-id
Nov 24, 2026
Merged

scottcrawford03 merged 2 commits into
block:mainfrom
nandiheath:nandi/reclaim-deleted-app-id

Conversation

@nandiheath

@nandiheath nandiheath commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

After bl apps delete, there was no way to create the same app ID again through bl:

  • bl apps create stopped at reserve with app_id_collision.
  • bl apps initialize refused any app with deleted_at on the client side.

So a deleted static site could not be re-created, for example as fetch-js with MySQL, under the same URL. People created -v2 IDs instead.

The control plane already reclaims a deleted app ID through initialize, as a fresh lifecycle. squareup/blockplat-compose#667 makes plan and reserve lead clients to that path.

Changes

  • bl apps create: when reserve fails with app_deleted (newer servers) or app_id_collision (older servers), create already inspects the app. If the app is deleted, create now reclaims it through initialize with the planned runtime profile and persistence, and the output reports reclaimed: true.
    • Initialize runs even when the plan is static. Only initialize reclaims a deleted ID; deploy refuses it.
    • While the deleted app's cleanup is still finishing, the server answers app_deleted. The error says to wait a few minutes and retry the same command.
  • --private on a reclaim: visibility is applied after initialize, because a deleted app has no live route to change and the reclaimed route publishes no version. If that step fails, the recovery message points to bl apps visibility <id> private only. Retrying create cannot resume a reclaimed app.
  • bl apps initialize: still refuses deleted apps. The message now points to bl apps create.
  • Docs: help text and README.md explain how to reuse a deleted app's ID. Sharing, publishers, versions and data are not carried over.

Verification

  • New process tests:
    • Reclaim as fetch-js+mysql via app_deleted.
    • Static reclaim from an older server's app_id_collision with a no-initialize plan.
    • Cleanup still running.
    • --private ordering on reclaim.
    • Visibility failure after a reclaim.
  • just check (fmt, clippy -D warnings, all tests) passes.

Staging verification (bb-block staging, 2026-11-19/20)

The control plane ran blockplat-compose main 277e2141, which includes squareup/blockplat-compose#667, squareup/blockplat-compose#669 and squareup/blockplat-compose#673. bl was built from this branch before the rebase onto main; the rebase only adapted the code to the create_app refactor in #53. Test app reclaim-e2e-1119:

  1. Static site. bl apps create --runtime-profile static and deploy. Ready, with an expiration record, so it exercised the static-lifecycle release path.
  2. Delete, then immediately bl apps create --runtime-profile fetch-js --persistence mysql. Plan accepted fetch-js + MySQL (this failed with mysql_profile_unsupported before #667) and reserve answered app_deleted. Initialize returned 409 app_deleted, and the CLI printed the "cleanup is still finishing, retry" message.
  3. Same command 27 minutes later: reclaimed: true, same external_url, fetch-js + mysql, new app_incarnation_id. reclaim_ready_at was never published in the meantime, so initialize's lazy finalization did the work. Not requiring reclaim_ready_at on the client is therefore necessary.
  4. MySQL site. Deployed a fetch-js MySQL site, which became ready. Through bl curl at the original URL:
    • /api/db: MySQL 8.0.42 through the app's proxy.
    • /api/db/write: inserted a row.
    • /api/db/read: returned the row, and returned it again after a redeploy.

Rollout

The server side is merged: squareup/blockplat-compose#667, #669 and #673. Older servers reject the static → fetch-js + MySQL plan with mysql_profile_unsupported. With an older server, same-profile reclaims still work through the app_id_collision fallback.

bl apps create stopped at reserve for a deleted app's ID, and
bl apps initialize refused it client-side, so a deleted static site could
not be re-created, e.g. as fetch-js with MySQL, under the same URL.

When reserve fails and the app turns out to be deleted (newer servers
answer app_deleted, older ones app_id_collision), create now reclaims it
through initialize, even for a static plan, and reports reclaimed: true.
--private is applied after the reclaim because a deleted app has no live
route to change. initialize keeps refusing deleted apps and points to
create.

Signed-off-by: Nandi Wong <nand0315@gmail.com>
@nandiheath
nandiheath force-pushed the nandi/reclaim-deleted-app-id branch from c8bbe1e to 1a2a459 Compare November 20, 2026 21:21
@nandiheath
nandiheath marked this pull request as ready for review November 20, 2026 21:22
@nandiheath
nandiheath requested a review from a team as a code owner November 20, 2026 21:22
@scottcrawford03

Copy link
Copy Markdown
Contributor

Automated review

APPROVE WITH CAUTION — Reclaim flow is correct; one nonblocking issue: on a reclaim, --private is applied only after initialize's response checks pass, so a failed check leaves the reclaimed app public. (per claude)

From claude:

F1 — [INFO] Reclaim checks initialize's response before applying --private

Location:

builderlab-cli/src/bl/apps.rs

Lines 1472 to 1483 in 1a2a459

let initialized_app_id =
required_response_string(&response, "app_id", "Apps Platform initialize")?;
require_exact_app_id("initialize", &app_id, initialized_app_id)
.map_err(|error| correlate_response_error(error, &response))?;
confirm_mysql_initialization(&response, mysql_requested)?;
Some(response)
} else {
None
};
if reclaimed {
visibility = make_private()?;
}

On a reclaim, make_private() now runs after the post-initialize checks: required_response_string("app_id"), require_exact_app_id, and confirm_mysql_initialization. Suppose bl apps create --private --persistence mysql reclaims a deleted ID, initialize returns 2xx, and then a check fails, for example because the response does not echo persistence: "mysql". The ? returns before visibility is set. The server has already reclaimed the app, but it is not private. The error the user sees ("inspect the app before deploying", or an app_id mismatch) does not say the app was reclaimed or that bl apps visibility <id> private is still needed. These checks are outside the reclaim with_context message, which wraps only the client.initialize call. Before this change, private was always applied before initialize, so this path could not leave a --private app public. Nothing is served until a version is deployed. But if the user next runs a non-static bl apps deploy, the app goes live publicly, and that path has no --private access check. Fix: on a reclaim, call make_private() as soon as client.initialize returns Ok, before validating the response. Alternatively, add the bl apps visibility {app_id} private instruction to these checks' errors when reclaimed && private.

Reviewed at commit 1a2a459.

On a reclaim, --private was applied only after initialize's response
passed its app ID and MySQL checks. A 2xx response that failed a check
ended the command with the reclaimed app still visible to its workspace.
Apply visibility as soon as initialize returns, before those checks.

Signed-off-by: Nandi Wong <nand0315@gmail.com>
@nandiheath

Copy link
Copy Markdown
Contributor Author

🤖  Thanks, F1 was valid. It's fixed in 656dfa4 (comment).

  • Fix. On a reclaim, create_app now applies --private as soon as client.initialize returns Ok, before the app_id/MySQL response checks. A failed check can no longer leave the reclaimed app visible. The later make_private() call is gone.
  • Regression test. bl_apps_create_private_reclaim_sets_visibility_before_checking_initialize reclaims with --private --persistence mysql and an initialize response that fails the MySQL check. It asserts the command fails and that the visibility PUT still follows initialize. It fails on 1a2a459 and passes with the fix.
  • Checks. just check (fmt, clippy -D warnings, all tests) passes, and a local Codex review of the full PR diff found no actionable issues.

@scottcrawford03
scottcrawford03 merged commit fae1f00 into block:main Nov 24, 2026
4 checks passed
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