Skip to content

fix(cli): honor SUPABASE_INTERNAL_IMAGE_REGISTRY in gen types - #5786

Merged
jgoux merged 3 commits into
supabase:developfrom
swiflyme:fix/gen-types-honor-internal-image-registry
Jul 6, 2026
Merged

fix(cli): honor SUPABASE_INTERNAL_IMAGE_REGISTRY in gen types#5786
jgoux merged 3 commits into
supabase:developfrom
swiflyme:fix/gen-types-honor-internal-image-registry

Conversation

@swiflyme

@swiflyme swiflyme commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

What

Make supabase gen types --local honor SUPABASE_INTERNAL_IMAGE_REGISTRY for any registry when pulling the postgres-meta image, instead of only special-casing docker.io.

Closes #5785.

Why

On GitHub-hosted runners (shared egress IPs), public.ecr.aws is frequently rate-limited. supabase/setup-cli exports SUPABASE_INTERNAL_IMAGE_REGISTRY=ghcr.io precisely to avoid this (core.exportVariable(CLI_CONFIG_REGISTRY, "ghcr.io")). supabase start honors it, but gen types did not: it kept running docker run public.ecr.aws/supabase/postgres-meta:<tag> and failed with

docker: toomanyrequests: Rate exceeded

even with SUPABASE_INTERNAL_IMAGE_REGISTRY=ghcr.io set in the step env.

Root cause

  • apps/cli/src/legacy/commands/gen/types/types.handler.tsrunPgMeta spawns the container with resolvePgmetaImage(...).
  • apps/cli/src/legacy/commands/gen/types/types.shared.tsresolvePgmetaImage only special-cased SUPABASE_INTERNAL_IMAGE_REGISTRY === "docker.io"; any other value fell through to dockerImageForService.
  • packages/stack/src/versions.tsdockerImageForService hardcodes DEFAULT_REGISTRY = "public.ecr.aws/supabase" and does not read the env var.

The Go CLI honored the override (with multi-registry fallback) via GetRegistryImageUrl in apps/cli-go/internal/utils/docker.go, so this is a regression in the TypeScript rewrite.

How

Resolve the image through the existing legacyGetRegistryImageUrl helper (apps/cli/src/legacy/shared/legacy-docker-registry.ts) — the documented 1:1 port of Go's GetRegistryImageUrl, already used by supabase start and test db (test/db/db.handler.ts for pg_prove). It honors SUPABASE_INTERNAL_IMAGE_REGISTRY for any registry, returns Docker Hub images unchanged for docker.io, and defaults to the ECR mirror when unset.

Output is unchanged in the two pre-existing cases:

SUPABASE_INTERNAL_IMAGE_REGISTRY before after
(unset) public.ecr.aws/supabase/postgres-meta:v<tag> public.ecr.aws/supabase/postgres-meta:v<tag>
docker.io supabase/postgres-meta:v<tag> supabase/postgres-meta:v<tag>
ghcr.io public.ecr.aws/supabase/postgres-meta:v<tag> ghcr.io/supabase/postgres-meta:v<tag>
my.registry public.ecr.aws/supabase/postgres-meta:v<tag> my.registry/supabase/postgres-meta:v<tag>

Tests

Added regression guards in types.unit.test.ts for the default (ECR), ghcr.io, and an arbitrary mirror. The ghcr.io case fails against the old code.

  • types.unit.test.ts: 26/26 pass
  • types.integration.test.ts: 71/71 pass
  • types:check / lint:check / fmt:check / knip:check: clean

`supabase gen types --local` spawns postgres-meta via a direct
`docker run public.ecr.aws/supabase/postgres-meta:<tag>` and ignores
`SUPABASE_INTERNAL_IMAGE_REGISTRY` for any value other than `docker.io`.
`resolvePgmetaImage` only special-cased `docker.io` and otherwise fell
through to `dockerImageForService`, whose registry is hardcoded to
`public.ecr.aws/supabase`.

On shared GitHub runners `supabase/setup-cli` exports
`SUPABASE_INTERNAL_IMAGE_REGISTRY=ghcr.io` precisely to avoid ECR
throttling, but gen types kept pulling from ECR and failed with
`docker: toomanyrequests: Rate exceeded`. The Go CLI honored the
override via `GetRegistryImageUrl` (with multi-registry fallback).

Resolve the image through the existing `legacyGetRegistryImageUrl`
helper (the 1:1 TS port of Go's `GetRegistryImageUrl`, already used by
`supabase start` / `test db`), so the override is honored for any
registry while ECR stays the default when unset. Output is unchanged
for the unset and `docker.io` cases.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@swiflyme
swiflyme requested a review from a team as a code owner July 5, 2026 07:51

@jgoux jgoux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! 🙏

@jgoux
jgoux added this pull request to the merge queue Jul 6, 2026
Merged via the queue into supabase:develop with commit 1439680 Jul 6, 2026
13 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.

gen types --local ignores SUPABASE_INTERNAL_IMAGE_REGISTRY and always pulls postgres-meta from public.ecr.aws (regression from Go CLI)

2 participants