Skip to content
This repository was archived by the owner on Apr 22, 2026. It is now read-only.

Commit af26549

Browse files
koki-developclaude
andcommitted
fix: make run field optional in ExecuteResponse to match compile
Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b6f2135 commit af26549

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

src/client.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ describe("Piston", () => {
238238
expect(result.compile).toBeDefined();
239239
expect(result.compile?.cpuTime).toBe(1000);
240240
expect(result.compile?.wallTime).toBe(1200);
241-
expect(result.run.cpuTime).toBe(5);
242-
expect(result.run.wallTime).toBe(50);
241+
expect(result.run?.cpuTime).toBe(5);
242+
expect(result.run?.wallTime).toBe(50);
243243
});
244244

245245
it("should handle runtime error status", async () => {
@@ -270,8 +270,8 @@ describe("Piston", () => {
270270
files: [{ content: "print(undefined)" }],
271271
});
272272

273-
expect(result.run.status).toBe("RE");
274-
expect(result.run.code).toBe(1);
273+
expect(result.run?.status).toBe("RE");
274+
expect(result.run?.code).toBe(1);
275275
});
276276

277277
it("should handle timeout status", async () => {
@@ -302,9 +302,9 @@ describe("Piston", () => {
302302
files: [{ content: "while True: pass" }],
303303
});
304304

305-
expect(result.run.status).toBe("TO");
306-
expect(result.run.signal).toBe("SIGKILL");
307-
expect(result.run.code).toBeNull();
305+
expect(result.run?.status).toBe("TO");
306+
expect(result.run?.signal).toBe("SIGKILL");
307+
expect(result.run?.code).toBeNull();
308308
});
309309

310310
it("should handle signal termination", async () => {
@@ -347,8 +347,8 @@ describe("Piston", () => {
347347
files: [{ content: "int main() { int *p = 0; *p = 1; }" }],
348348
});
349349

350-
expect(result.run.status).toBe("SG");
351-
expect(result.run.signal).toBe("SIGSEGV");
350+
expect(result.run?.status).toBe("SG");
351+
expect(result.run?.signal).toBe("SIGSEGV");
352352
});
353353
});
354354

src/client.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ interface RawExecuteResponse {
6060
language: string;
6161
version: string;
6262
compile?: RawStageResult;
63-
run: RawStageResult;
63+
run?: RawStageResult;
6464
}
6565

6666
/**
@@ -284,13 +284,16 @@ export class Piston {
284284
const result: ExecuteResponse = {
285285
language: raw.language,
286286
version: raw.version,
287-
run: this.toStageResult(raw.run),
288287
};
289288

290289
if (raw.compile) {
291290
result.compile = this.toStageResult(raw.compile);
292291
}
293292

293+
if (raw.run) {
294+
result.run = this.toStageResult(raw.run);
295+
}
296+
294297
return result;
295298
}
296299

src/types/response.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export interface ExecuteResponse {
8282
* Run stage result.
8383
* Always present.
8484
*/
85-
run: StageResult;
85+
run?: StageResult;
8686
}
8787

8888
/**

0 commit comments

Comments
 (0)