Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,8 @@ export class RunAttemptSystem {
return startSpan(this.$.tracer, "permanentlyFailRun", async (span) => {
const status = runStatusFromError(error, latestSnapshot.environmentType);

const truncatedError = this.#truncateTaskRunError(error);

//run permanently failed
const run = await prisma.taskRun.update({
where: {
Expand All @@ -1484,7 +1486,7 @@ export class RunAttemptSystem {
data: {
status,
completedAt: failedAt,
error,
error: truncatedError,
},
select: {
id: true,
Expand Down Expand Up @@ -1546,7 +1548,7 @@ export class RunAttemptSystem {

await this.waitpointSystem.completeWaitpoint({
id: run.associatedWaitpoint.id,
output: { value: JSON.stringify(error), isError: true },
output: { value: JSON.stringify(truncatedError), isError: true },
});

this.$.eventBus.emit("runFailed", {
Expand Down Expand Up @@ -1892,6 +1894,19 @@ export class RunAttemptSystem {
});
}
}

#truncateTaskRunError(error: TaskRunError): TaskRunError {
if (error.type !== "BUILT_IN_ERROR") {
return error;
}

return {
type: "BUILT_IN_ERROR",
name: truncateString(error.name, 1024),
message: truncateString(error.message, 1024 * 16), // 16kb
stackTrace: truncateString(error.stackTrace, 1024 * 16), // 16kb
};
}
}

export function safeParseGitMeta(git: unknown): GitMeta | undefined {
Expand All @@ -1901,3 +1916,11 @@ export function safeParseGitMeta(git: unknown): GitMeta | undefined {
}
return undefined;
}

function truncateString(str: string | undefined, maxLength: number): string {
if (!str) {
return "";
}

return str.slice(0, maxLength);
}
Loading