fix(start): suggest recovery for exec format and backup migration failures#5937
Conversation
…lures Surface actionable CmdSuggestion when unhealthy containers log exec format error, storage migrations_name_key, or Studio ERR_INVALID_PACKAGE_CONFIG, and pin image pulls to linux/<host-arch> to reduce wrong-arch Mailpit starts.
|
👋 Thanks for the contribution! This pull request isn't linked to a tracked issue, so it's being closed automatically. Please open an issue first, wait for a maintainer to add the |
|
👋 Thanks for the contribution! This pull request isn't linked to a tracked issue, so it's being closed automatically. Please open an issue first, wait for a maintainer to add the |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4031555019
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| "A container failed with \"exec format error\" (wrong CPU architecture image).\n"+ | ||
| "Try removing the mismatched images and restarting for linux/%s:\n"+ | ||
| " %s\n"+ | ||
| " docker image prune -f\n"+ |
There was a problem hiding this comment.
Remove tagged images for exec-format recovery
When the exec-format failure is caused by a tagged local image with the wrong architecture, this recovery leaves it in place: Docker documents that docker image prune removes dangling images by default and only removes other unused images with -a (https://docs.docker.com/reference/cli/docker/image/prune/), while DockerResolveImageIfNotCached returns any locally inspectable tag before reaching the new platform-pinned pull. After supabase stop --no-backup && docker image prune -f, supabase start can reuse the same tagged wrong-arch image and hit exec format error again; the hint should remove the affected Supabase image tag(s) or force a platform-aware repull.
Useful? React with 👍 / 👎.
| parts = append(parts, fmt.Sprintf( | ||
| "Studio image looks corrupted or incomplete. Remove it and re-pull:\n"+ | ||
| " %s\n"+ | ||
| " docker image rm -f $(docker images -q supabase/studio) 2>/dev/null\n"+ |
There was a problem hiding this comment.
Remove mirrored Studio images too
For the default registry path, Studio is cached as public.ecr.aws/supabase/studio (and the fallback can be ghcr.io/supabase/studio), but this command only asks Docker for the exact repository supabase/studio; Docker's image-list docs state the [REPOSITORY[:TAG]] argument must be an exact match (https://docs.docker.com/reference/cli/docker/image/ls/). In the corrupted default/fallback image scenario the command produces no IDs, removes nothing, and the next supabase start reuses the broken Studio image, so the hint should match the configured/mirrored repository names instead of only Docker Hub.
Useful? React with 👍 / 👎.
| RegistryAuth: GetRegistryAuthForImage(imageTag), | ||
| // Prefer the host architecture so services like mailpit do not start | ||
| // with a wrong-arch binary (exec format error). See supabase/supabase#48224. | ||
| Platform: "linux/" + runtime.GOARCH, |
There was a problem hiding this comment.
Use the Docker daemon architecture
When the CLI talks to a Docker daemon with a different architecture than the CLI binary, such as an amd64 CLI using a remote arm64 Docker context/DOCKER_HOST or Rosetta, this forces pulls to linux/<runtime.GOARCH>. Docker's pull option explicitly sets the platform (https://docs.docker.com/reference/cli/docker/image/pull/), so the daemon can receive an image for the client architecture rather than the daemon architecture and then fail to run it without emulation; derive the platform from the daemon or make the override conditional.
Useful? React with 👍 / 👎.
| fmt.Fprintln(os.Stderr, logErr) | ||
| } | ||
| } | ||
| if suggestion := SuggestFromUnhealthyLogs(logBuf.String()); len(suggestion) > 0 { |
There was a problem hiding this comment.
Scope destructive recovery hints to stack startup
When WaitForHealthyService is used for temporary containers outside supabase start (for example the db diff shadow database in apps/cli-go/internal/db/diff/shadow.go), this unconditional log scan can surface suggestions that tell users to run supabase stop --no-backup. In those contexts the local stack volume is not the failed resource, and following the hint can delete local development data unnecessarily; only add these recovery steps for local-stack startup checks or tailor them per caller.
Useful? React with 👍 / 👎.
| RegistryAuth: GetRegistryAuthForImage(imageTag), | ||
| // Prefer the host architecture so services like mailpit do not start | ||
| // with a wrong-arch binary (exec format error). See supabase/supabase#48224. | ||
| Platform: "linux/" + runtime.GOARCH, |
There was a problem hiding this comment.
Pin the compose pre-pull path too
In supabase start, the first pull attempt is pullImagesUsingCompose (apps/cli-go/internal/start/start.go:284), whose RetryClient.ImagePull forwards Docker's pull options without setting a platform; only images that compose skipped reach this new platform-pinned DockerImagePull. If the normal compose pre-pull is the path that fetches a wrong-arch tag, ensureImagesCached then sees the tag locally and never executes this pinned pull, so the Mailpit exec-format failure can still happen on an empty cache unless the compose pull path is pinned or disabled as well.
Useful? React with 👍 / 👎.
Summary
When
supabase starthealth checks fail, detect common log patterns (exec format error, storagemigrations_name_key, StudioERR_INVALID_PACKAGE_CONFIG) and setCmdSuggestionwith recovery steps. Also pin image pulls tolinux/<host-arch>to reduce wrong-arch Mailpit starts.Related: supabase/supabase#48224
Linked issue
Closes #REPLACE_WITH_CLI_ISSUE_NUMBER
open-for-contributionlabel (or I'm a Supabase maintainer).Checklist
pnpm check:allandpnpm testpass for the workspace(s) I touched.