Skip to content

Commit 164afe6

Browse files
fix(logs): guard transformResponse on non-2xx and correct executionMetadata description
- Add response.ok check in all three logs tools' transformResponse so a 4xx/5xx body cannot be silently treated as a success payload (defense in depth; the executor already throws on non-2xx before transform runs). - Drop totalTokens from executionMetadata description in block and tool outputs since the snapshot route does not emit it.
1 parent b1abd72 commit 164afe6

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

apps/sim/blocks/blocks/logs.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ export const LogsBlock: BlockConfig = {
247247
},
248248
executionMetadata: {
249249
type: 'json',
250-
description:
251-
'Trigger, timestamps, totalDurationMs, cost, totalTokens (get_execution operation)',
250+
description: 'Trigger, timestamps, totalDurationMs, cost (get_execution operation)',
252251
},
253252
},
254253
}

apps/sim/tools/logs/get_execution.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ export const logsGetExecutionTool: ToolConfig<LogsGetExecutionParams, LogsGetExe
2727

2828
transformResponse: async (response): Promise<LogsGetExecutionResponse> => {
2929
const data = await response.json()
30+
if (!response.ok) {
31+
throw new Error(data?.error || `Request failed with status ${response.status}`)
32+
}
3033
return {
3134
success: true,
3235
output: data,
@@ -44,7 +47,7 @@ export const logsGetExecutionTool: ToolConfig<LogsGetExecutionParams, LogsGetExe
4447
},
4548
executionMetadata: {
4649
type: 'json',
47-
description: 'Trigger, timestamps, totalDurationMs, cost, and totalTokens for the run',
50+
description: 'Trigger, timestamps, totalDurationMs, and cost for the run',
4851
},
4952
},
5053
}

apps/sim/tools/logs/get_log.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export const logsGetTool: ToolConfig<LogsGetParams, LogsGetResponse> = {
3333

3434
transformResponse: async (response): Promise<LogsGetResponse> => {
3535
const result = await response.json()
36+
if (!response.ok) {
37+
throw new Error(result?.error || `Request failed with status ${response.status}`)
38+
}
3639
return {
3740
success: true,
3841
output: {

apps/sim/tools/logs/query.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ export const logsQueryTool: ToolConfig<LogsQueryParams, LogsQueryResponse> = {
107107

108108
transformResponse: async (response): Promise<LogsQueryResponse> => {
109109
const result = await response.json()
110+
if (!response.ok) {
111+
throw new Error(result?.error || `Request failed with status ${response.status}`)
112+
}
110113
return {
111114
success: true,
112115
output: {

0 commit comments

Comments
 (0)