Skip to content

Commit a609100

Browse files
committed
Chore: Add changeset for file operation error handling fix
1 parent b8dffee commit a609100

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@perstack/runtime": patch
3+
---
4+
5+
Handle file read errors gracefully in resolving PDF and image file states

packages/runtime/src/states/resolving-image-file.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ describe("@perstack/runtime: StateMachineLogic['ResolvingImageFile']", () => {
121121
skillManagers: {},
122122
})
123123
expect(result.type).toBe("finishToolCall")
124-
expect(result.newMessages[0].contents[0].contents[0]).toMatchObject({
124+
if (result.type !== "finishToolCall") throw new Error("Unexpected event type")
125+
const toolResultPart = result.newMessages[0].contents[0]
126+
if (toolResultPart.type !== "toolResultPart") throw new Error("Unexpected part type")
127+
expect(toolResultPart.contents[0]).toMatchObject({
125128
type: "textPart",
126129
text: expect.stringContaining('Failed to read image file "/nonexistent.png"'),
127130
})

packages/runtime/src/states/resolving-pdf-file.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ describe("@perstack/runtime: StateMachineLogic['ResolvingPdfFile']", () => {
132132
skillManagers: {},
133133
})
134134
expect(result.type).toBe("finishToolCall")
135+
if (result.type !== "finishToolCall") throw new Error("Unexpected event type")
135136
const userMessage = result.newMessages[1]
136137
expect(userMessage.contents[0]).toMatchObject({
137138
type: "textPart",

0 commit comments

Comments
 (0)