Skip to content

Commit 8d73d80

Browse files
committed
feat(core,webapp): return externalId from the deployments API
The column has always existed and the dashboard reads it, but no public endpoint returned it, so callers had no way to tell which deployment a version skew protection pin resolves to. It is now on deployments.list(), deployments.retrieveCurrent() and the single-deployment retrieve. The list route already loads the whole row, so only the projection changed. The current-deployment route needed the column added to its select as well. Also stops that same projection throwing on a deployment with no git metadata: the response schema rejects null, so one API-created deployment hid every other row on the page. GetDeploymentResponseBody uses optional rather than nullish so it stays assignable to the CLI's narrower InitializeDeploymentResponseBody, which it is spread into when a deploy attaches to an existing deployment.
1 parent 3eb9bd6 commit 8d73d80

6 files changed

Lines changed: 31 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/core": patch
3+
---
4+
5+
`deployments.list()` and `deployments.retrieveCurrent()` now return `externalId`, the `--external-id` a deployment was deployed under, so you can tell which deployment a version skew protection pin resolves to. Null for deployments deployed without one.

apps/webapp/app/routes/api.v1.deployments.$deploymentId.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
6262
imageReference: deployment.imageReference,
6363
imagePlatform: deployment.imagePlatform,
6464
commitSHA: deployment.commitSHA,
65+
externalId: deployment.externalId ?? undefined,
6566
externalBuildData:
6667
deployment.externalBuildData as GetDeploymentResponseBody["externalBuildData"],
6768
errorData: deployment.errorData as GetDeploymentResponseBody["errorData"],

apps/webapp/app/routes/api.v1.deployments.current.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const loader = createLoaderApiRoute(
2929
deployedAt: true,
3030
git: true,
3131
errorData: true,
32+
externalId: true,
3233
},
3334
},
3435
},
@@ -49,6 +50,7 @@ export const loader = createLoaderApiRoute(
4950
deployedAt: deployment.deployedAt ?? undefined,
5051
git: deployment.git ?? undefined,
5152
error: deployment.errorData ?? undefined,
53+
externalId: deployment.externalId ?? undefined,
5254
});
5355
}
5456
);

apps/webapp/app/routes/api.v1.deployments.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,9 @@ export const loader = createLoaderApiRoute(
135135
runtimeVersion: deployment.runtimeVersion,
136136
status: deployment.status,
137137
deployedAt: deployment.deployedAt,
138-
git: deployment.git,
138+
git: deployment.git ?? undefined,
139139
error: deployment.errorData ?? undefined,
140+
externalId: deployment.externalId ?? undefined,
140141
})),
141142
pagination: {
142143
next: nextCursor,

docs/v3-openapi.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,12 @@ paths:
895895
type: object
896896
nullable: true
897897
description: Error data if the deployment failed
898+
externalId:
899+
type: string
900+
nullable: true
901+
description: >-
902+
The external deployment id this deployment was deployed under
903+
(`--external-id`), used by version skew protection to pin runs
898904
pagination:
899905
type: object
900906
properties:

packages/core/src/v3/schemas/api.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,15 @@ export const GetDeploymentResponseBody = z.object({
921921
imageReference: z.string().nullish(),
922922
imagePlatform: z.string(),
923923
commitSHA: z.string().nullish(),
924+
/**
925+
* The `--external-id` this deployment was deployed under, used by version skew
926+
* protection to pin runs. Distinct from `commitSHA`, which is git metadata.
927+
*
928+
* `optional`, not `nullish`, to stay assignable to the CLI's narrower
929+
* `InitializeDeploymentResponseBody` shape, which this is spread into on the
930+
* attach-to-existing-deployment path (`cli-v3/src/commands/deploy.ts:1156`).
931+
*/
932+
externalId: z.string().optional(),
924933
externalBuildData: ExternalBuildData.optional().nullable(),
925934
errorData: DeploymentErrorData.nullish(),
926935
canceledReason: z.string().nullish(),
@@ -2201,6 +2210,12 @@ export const ApiDeploymentListResponseItem = z.object({
22012210
deployedAt: z.coerce.date().optional(),
22022211
git: z.record(z.any()).optional(),
22032212
error: DeploymentErrorData.optional(),
2213+
/**
2214+
* The `--external-id` this deployment was deployed under, used by version skew
2215+
* protection to pin runs. Nullish on deployments created without one, and on
2216+
* servers older than this field.
2217+
*/
2218+
externalId: z.string().nullish(),
22042219
});
22052220

22062221
export type ApiDeploymentListResponseItem = z.infer<typeof ApiDeploymentListResponseItem>;

0 commit comments

Comments
 (0)