Make the authenticated env optional when updating run metadata
🚀 Publish Trigger.dev Docker / units (push) Failing after 10m52s
🚀 Publish Trigger.dev Docker / typecheck (push) Failing after 11m48s
🚀 Publish Trigger.dev Docker / publish-webapp (push) Has been skipped
🚀 Publish Trigger.dev Docker / publish-worker (push) Has been skipped

This commit is contained in:
Eric Allam
2025-01-08 20:04:05 +00:00
parent 86b088c818
commit 55da7c773b
3 changed files with 13 additions and 9 deletions
@@ -16,7 +16,7 @@ const { action } = createActionApiRoute(
method: "PUT",
},
async ({ authentication, body, params }) => {
const result = await updateMetadataService.call(authentication.environment, params.runId, body);
const result = await updateMetadataService.call(params.runId, body, authentication.environment);
if (!result) {
return json({ error: "Task Run not found" }, { status: 404 });
@@ -229,17 +229,21 @@ export class UpdateMetadataService extends BaseService {
}
public async call(
environment: AuthenticatedEnvironment,
runId: string,
body: UpdateMetadataRequestBody
body: UpdateMetadataRequestBody,
environment?: AuthenticatedEnvironment
) {
const runIdType = runId.startsWith("run_") ? "friendly" : "internal";
const taskRun = await this._prisma.taskRun.findFirst({
where: {
runtimeEnvironmentId: environment.id,
...(runIdType === "internal" ? { id: runId } : { friendlyId: runId }),
},
where: environment
? {
runtimeEnvironmentId: environment.id,
...(runIdType === "internal" ? { id: runId } : { friendlyId: runId }),
}
: {
...(runIdType === "internal" ? { id: runId } : { friendlyId: runId }),
},
select: {
id: true,
status: true,
@@ -70,9 +70,9 @@ export class FinalizeTaskRunService extends BaseService {
completedAt,
});
if (env && metadata) {
if (metadata) {
try {
await updateMetadataService.call(env, id, metadata);
await updateMetadataService.call(id, metadata, env);
} catch (e) {
logger.error("[FinalizeTaskRunService] Failed to update metadata", {
taskRun: id,