Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions apps/cli/scripts/detect-unmirrored-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,36 @@ export async function partitionUnmirroredImages(
};
}

/**
* Interprets a `docker buildx imagetools inspect` result. Only a registry "not found" means the
* image is unmirrored; any other failure (auth, rate limit, network) throws, so a registry outage
* fails detection instead of re-pushing every image.
*/
export function inspectResultIsMirrored(
target: string,
exit: number | NodeJS.Signals | null,
stderr: string,
): boolean {
if (exit === 0) {
return true;
}
if (stderr.trimEnd().endsWith(": not found")) {
return false;
}
throw new Error(`could not inspect ${target} (exit ${exit}): ${stderr.trim()}`);
Comment on lines +80 to +83

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.

🟡 MINOR · error-handling · source: claude

Backfilling a previously nonexistent mirror repository may fail if GHCR or ECR Public reports its absence as an authorization or repository-unknown error rather than stderr ending in ': not found'. The detector throws for those responses, preventing the mirror job from running.

Evidence: apps/cli/scripts/detect-unmirrored-images.ts:77-83 accepts successful probes and ': not found' failures only. Errors propagate through partitionUnmirroredImages at lines 52-59 and its top-level invocation at line 101. .github/workflows/mirror-template-images.yml:40-68 grants packages:read, logs into GHCR, and runs detection without an ECR login; lines 70-83 make mirroring depend on detection. detect-unmirrored-images.unit.test.ts:64-78 covers a synthetic not-found response and a network timeout, but no actual missing-repository response.

Suggested fix: Capture missing-repository responses from both registries under the workflow's authentication conditions. Add regression cases for any verified absence responses and handle them narrowly while retaining failures for genuine authentication, rate-limit, and network errors.

Adjudication (uncertain): The surrounding code confirms that any nonmatching error aborts detection and prevents backfilling. However, neither the implementation nor its tests establishes that GHCR or ECR Public returns the alleged authorization or repository-unknown response for an absent repository under these credentials. No registry reproduction was performed, so the central premise cannot be confirmed or refuted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

develop added this strict error handling in detect-unmirrored-images.ts in #7194, so the merge did not introduce it and it is out of scope for this sync. If GHCR or ECR Public really do report missing repositories in another way, a follow-up PR against develop should handle that.

}

function imageExistsOnMirror(target: string): Promise<boolean> {
const result = spawnSync("docker", ["buildx", "imagetools", "inspect", target], {
stdio: "ignore",
encoding: "utf8",
stdio: ["ignore", "ignore", "pipe"],
});
return Promise.resolve(result.status === 0);
if (result.error) {
throw result.error;
}
return Promise.resolve(
inspectResultIsMirrored(target, result.status ?? result.signal, result.stderr),
);
}

if (import.meta.main) {
Expand Down
18 changes: 18 additions & 0 deletions apps/cli/scripts/detect-unmirrored-images.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expect, test } from "vitest";
import {
inspectResultIsMirrored,
MIRROR_REGISTRIES,
mirrorImageTarget,
mirrorImageTargets,
Expand Down Expand Up @@ -59,4 +60,21 @@ describe("detect unmirrored images", () => {
expect(missing).toEqual([]);
expect(mirrored).toEqual(["postgrest/postgrest:v14.14", "supabase/logflare:1.45.6"]);
});

test("only a registry not-found marks an image as unmirrored", () => {
const target = "public.ecr.aws/supabase/realtime:v2.144.2";

expect(inspectResultIsMirrored(target, 0, "")).toBe(true);
expect(inspectResultIsMirrored(target, 1, `ERROR: ${target}: not found\n`)).toBe(false);
});

test("a failed registry probe aborts detection with the registry error", () => {
const target = "public.ecr.aws/supabase/realtime:v2.144.2";
const stderr =
'ERROR: failed to do request: Head "https://public.ecr.aws/v2/supabase/realtime/manifests/v2.144.2": dial tcp: i/o timeout\n';

expect(() => inspectResultIsMirrored(target, 1, stderr)).toThrow(
`could not inspect ${target} (exit 1): ${stderr.trim()}`,
);
});
});
2 changes: 1 addition & 1 deletion apps/cli/src/shared/services/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ FROM supabase/gotrue:v2.197.0 AS gotrue

FROM supabase/realtime:v2.144.2 AS realtime

FROM supabase/storage-api:v1.83.3 AS storage
FROM supabase/storage-api:v1.83.5 AS storage

FROM supabase/logflare:1.50.15 AS logflare
# One-shot job images (not started as long-running containers); differ's alias
Expand Down
18 changes: 9 additions & 9 deletions packages/stack/src/Artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,23 +267,23 @@ const definitions: Readonly<Record<ArtifactKind, ArtifactDefinition>> = {
storage: definition(
"storage",
{
upstreamVersion: "v1.83.3",
upstreamVersion: "v1.83.5",
revision: 0,
image:
"ghcr.io/supabase/cli/storage:v1.83.3-r0@sha256:ac03b8058499a192dc447cf7fc6db020f25230d12b282a49a6ba6367025354d0",
upstreamImage: "supabase/storage-api:v1.83.3",
"ghcr.io/supabase/cli/storage:v1.83.5-r0@sha256:f3f8d44d485db98f70ad6cc111d24f76340f1809e80484ebe7ffb5b18154b987",
upstreamImage: "supabase/storage-api:v1.83.5",
natives: {
"darwin-arm64": {
archive: "8208925fef22516668f700fb1fc80478fe2f80fa78452d65cda8862d7f277863",
manifest: "6349e482d794fb4d2aabdb347c4d6e6f62b920eef05e3da66e1b0f9826b196a4",
archive: "a65552e3422b4d6d9ce0dbdf134491bc4f1bb86fba3d4f8d896c90b9cbbd79fd",
manifest: "7d996c9f5ea530d9868d859cc3b63a81521abb95850850e2c59ef113d3207988",
},
"linux-amd64": {
archive: "eda8dc7b0da3ac7b41c52dc87daec5a1868bd9529c156b947c9a53080bd68c03",
manifest: "754ad2082ffac3f420094c20730c7bb58f4df25382312b2471d45b0af3368f4b",
archive: "3ca93a63704236ba4690e32d65d15b7d541554662896957bc4c79954515c2be1",
manifest: "cb684420dd7a7622cc558bb32163ad348cc87de808030f1a6e29616e9ab6d48b",
},
"linux-arm64": {
archive: "8520036ba99639e6014a5e222fc858aaceae1aff575db392711d5cd382a227da",
manifest: "dcfc813c207bd501d4d2b87aa62ae8ce77ec8f3e676989ce49cb5eeee656ba78",
archive: "98cb93dd48ed42a365d3ec132cabaceb53c9cbced5125ef53e65846c282328ce",
manifest: "89583266e67be95b64f47d9b2b8c333d939636ca6b6fc8619dc3db10f0def20b",
},
},
},
Expand Down
Loading