From 46204831f739c21c80f86f7efc2370fe10c37214 Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Sun, 5 Apr 2026 13:03:41 -0600 Subject: [PATCH 1/2] fix: extractImageTag misidentifies registry port as tag The naive split(":").pop() approach treated the port number in registry URLs (e.g. registry:5000/image) as the image tag. Now uses lastIndexOf(":") and checks if the suffix matches a port followed by a path (digits + slash), consistent with extractImageName. Closes #4082 --- apps/dokploy/__test__/deploy/github.test.ts | 19 +++++++++++++++++++ .../pages/api/deploy/[refreshToken].ts | 15 +++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/apps/dokploy/__test__/deploy/github.test.ts b/apps/dokploy/__test__/deploy/github.test.ts index d2e773dfc..9319f27d6 100644 --- a/apps/dokploy/__test__/deploy/github.test.ts +++ b/apps/dokploy/__test__/deploy/github.test.ts @@ -415,5 +415,24 @@ describe("Docker Image Name and Tag Extraction", () => { expect(extractImageTag("my-image:123")).toBe("123"); expect(extractImageTag("my-image:1")).toBe("1"); }); + + it("should return 'latest' for registry with port but no tag", () => { + expect(extractImageTag("registry.example.com:5000/myimage")).toBe( + "latest", + ); + expect(extractImageTag("registry:5000/fedora/httpd")).toBe("latest"); + expect(extractImageTag("localhost:5000/myapp")).toBe("latest"); + expect(extractImageTag("my-registry.io:443/org/app")).toBe("latest"); + }); + + it("should extract tag from registry with port and tag", () => { + expect(extractImageTag("registry:5000/image:tag")).toBe("tag"); + expect( + extractImageTag("registry.example.com:5000/myimage:v2.0"), + ).toBe("v2.0"); + expect(extractImageTag("localhost:5000/app:sha-abc123")).toBe( + "sha-abc123", + ); + }); }); }); diff --git a/apps/dokploy/pages/api/deploy/[refreshToken].ts b/apps/dokploy/pages/api/deploy/[refreshToken].ts index 1c57731a7..1a99c3a8e 100644 --- a/apps/dokploy/pages/api/deploy/[refreshToken].ts +++ b/apps/dokploy/pages/api/deploy/[refreshToken].ts @@ -319,8 +319,19 @@ export function extractImageTag(dockerImage: string | null) { return null; } - const tag = dockerImage.split(":").pop(); - return tag === dockerImage ? "latest" : tag; + const lastColonIndex = dockerImage.lastIndexOf(":"); + if (lastColonIndex === -1) { + return "latest"; + } + + const afterColon = dockerImage.substring(lastColonIndex + 1); + const isPortWithPath = /^\d{1,5}\//.test(afterColon); + + if (isPortWithPath) { + return "latest"; + } + + return afterColon; } /** From 8a043dcc5cd587edc2da2a576e9839aef2d3d90d Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sun, 5 Apr 2026 19:04:17 +0000 Subject: [PATCH 2/2] [autofix.ci] apply automated fixes --- apps/dokploy/__test__/deploy/github.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/dokploy/__test__/deploy/github.test.ts b/apps/dokploy/__test__/deploy/github.test.ts index 9319f27d6..104e108f1 100644 --- a/apps/dokploy/__test__/deploy/github.test.ts +++ b/apps/dokploy/__test__/deploy/github.test.ts @@ -427,9 +427,9 @@ describe("Docker Image Name and Tag Extraction", () => { it("should extract tag from registry with port and tag", () => { expect(extractImageTag("registry:5000/image:tag")).toBe("tag"); - expect( - extractImageTag("registry.example.com:5000/myimage:v2.0"), - ).toBe("v2.0"); + expect(extractImageTag("registry.example.com:5000/myimage:v2.0")).toBe( + "v2.0", + ); expect(extractImageTag("localhost:5000/app:sha-abc123")).toBe( "sha-abc123", );