Skip to content

Commit 54a00cf

Browse files
committed
Make the authenticated env optional when updating run metadata
1 parent 8892073 commit 54a00cf

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

apps/webapp/app/routes/api.v1.runs.$runId.metadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const { action } = createActionApiRoute(
1616
method: "PUT",
1717
},
1818
async ({ authentication, body, params }) => {
19-
const result = await updateMetadataService.call(authentication.environment, params.runId, body);
19+
const result = await updateMetadataService.call(params.runId, body, authentication.environment);
2020

2121
if (!result) {
2222
return json({ error: "Task Run not found" }, { status: 404 });

apps/webapp/app/services/metadata/updateMetadata.server.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,17 +229,21 @@ export class UpdateMetadataService extends BaseService {
229229
}
230230

231231
public async call(
232-
environment: AuthenticatedEnvironment,
233232
runId: string,
234-
body: UpdateMetadataRequestBody
233+
body: UpdateMetadataRequestBody,
234+
environment?: AuthenticatedEnvironment
235235
) {
236236
const runIdType = runId.startsWith("run_") ? "friendly" : "internal";
237237

238238
const taskRun = await this._prisma.taskRun.findFirst({
239-
where: {
240-
runtimeEnvironmentId: environment.id,
241-
...(runIdType === "internal" ? { id: runId } : { friendlyId: runId }),
242-
},
239+
where: environment
240+
? {
241+
runtimeEnvironmentId: environment.id,
242+
...(runIdType === "internal" ? { id: runId } : { friendlyId: runId }),
243+
}
244+
: {
245+
...(runIdType === "internal" ? { id: runId } : { friendlyId: runId }),
246+
},
243247
select: {
244248
id: true,
245249
status: true,

apps/webapp/app/v3/services/finalizeTaskRun.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ export class FinalizeTaskRunService extends BaseService {
7070
completedAt,
7171
});
7272

73-
if (env && metadata) {
73+
if (metadata) {
7474
try {
75-
await updateMetadataService.call(env, id, metadata);
75+
await updateMetadataService.call(id, metadata, env);
7676
} catch (e) {
7777
logger.error("[FinalizeTaskRunService] Failed to update metadata", {
7878
taskRun: id,

0 commit comments

Comments
 (0)