Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/athena/create-named-query/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
Comment on lines +58 to +63
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 ZodError response missing success: false

All 8 Athena routes, 7 CloudFormation routes, 7 CloudWatch routes, and 6 DynamoDB routes return { error: ... } on ZodError without a success field. Their successful responses all include success: true, so error responses should symmetrically include success: false. The commit title (fix(api): add success:false to ZodError responses for consistency) implies this was intentional, but these 28 routes were not updated.

This same pattern is missing in:

  • apps/sim/app/api/tools/athena/get-named-query/route.ts:57
  • apps/sim/app/api/tools/athena/get-query-execution/route.ts:66
  • apps/sim/app/api/tools/athena/get-query-results/route.ts:77
  • apps/sim/app/api/tools/athena/list-named-queries/route.ts:54
  • apps/sim/app/api/tools/athena/list-query-executions/route.ts:54
  • apps/sim/app/api/tools/athena/start-query/route.ts:71
  • apps/sim/app/api/tools/athena/stop-query/route.ts:46
  • All CloudFormation, CloudWatch, and DynamoDB routes in the same PR
Suggested change
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
if (error instanceof z.ZodError) {
return NextResponse.json(
{ success: false, error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}

const errorMessage =
error instanceof Error ? error.message : 'Failed to create Athena named query'
logger.error('CreateNamedQuery failed', { error: errorMessage })
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/athena/get-named-query/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage = error instanceof Error ? error.message : 'Failed to get Athena named query'
logger.error('GetNamedQuery failed', { error: errorMessage })
return NextResponse.json({ error: errorMessage }, { status: 500 })
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/athena/get-query-execution/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to get Athena query execution'
logger.error('GetQueryExecution failed', { error: errorMessage })
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/athena/get-query-results/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to get Athena query results'
logger.error('GetQueryResults failed', { error: errorMessage })
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/athena/list-named-queries/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to list Athena named queries'
logger.error('ListNamedQueries failed', { error: errorMessage })
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/athena/list-query-executions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to list Athena query executions'
logger.error('ListQueryExecutions failed', { error: errorMessage })
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/athena/start-query/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage = error instanceof Error ? error.message : 'Failed to start Athena query'
logger.error('StartQuery failed', { error: errorMessage })
return NextResponse.json({ error: errorMessage }, { status: 500 })
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/athena/stop-query/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage = error instanceof Error ? error.message : 'Failed to stop Athena query'
logger.error('StopQuery failed', { error: errorMessage })
return NextResponse.json({ error: errorMessage }, { status: 500 })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to describe stack drift detection status'
logger.error('DescribeStackDriftDetectionStatus failed', { error: errorMessage })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ export async function POST(request: NextRequest) {
output: { events },
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to describe CloudFormation stack events'
logger.error('DescribeStackEvents failed', { error: errorMessage })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ export async function POST(request: NextRequest) {
output: { stacks },
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to describe CloudFormation stacks'
logger.error('DescribeStacks failed', { error: errorMessage })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to detect CloudFormation stack drift'
logger.error('DetectStackDrift failed', { error: errorMessage })
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/cloudformation/get-template/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to get CloudFormation template'
logger.error('GetTemplate failed', { error: errorMessage })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export async function POST(request: NextRequest) {
output: { resources },
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to list CloudFormation stack resources'
logger.error('ListStackResources failed', { error: errorMessage })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to validate CloudFormation template'
logger.error('ValidateTemplate failed', { error: errorMessage })
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/cloudwatch/describe-alarms/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ export async function POST(request: NextRequest) {
output: { alarms: [...metricAlarms, ...compositeAlarms] },
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to describe CloudWatch alarms'
logger.error('DescribeAlarms failed', { error: errorMessage })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ export async function POST(request: NextRequest) {
output: { logGroups },
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to describe CloudWatch log groups'
logger.error('DescribeLogGroups failed', { error: errorMessage })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export async function POST(request: NextRequest) {
output: { logStreams: result.logStreams },
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to describe CloudWatch log streams'
logger.error('DescribeLogStreams failed', { error: errorMessage })
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/cloudwatch/get-log-events/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ export async function POST(request: NextRequest) {
output: { events: result.events },
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to get CloudWatch log events'
logger.error('GetLogEvents failed', { error: errorMessage })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to get CloudWatch metric statistics'
logger.error('GetMetricStatistics failed', { error: errorMessage })
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/cloudwatch/list-metrics/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ export async function POST(request: NextRequest) {
output: { metrics },
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'Failed to list CloudWatch metrics'
logger.error('ListMetrics failed', { error: errorMessage })
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/cloudwatch/query-logs/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage =
error instanceof Error ? error.message : 'CloudWatch Log Insights query failed'
logger.error('QueryLogs failed', { error: errorMessage })
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/dynamodb/delete/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export async function POST(request: NextRequest) {
message: 'Item deleted successfully',
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage = error instanceof Error ? error.message : 'DynamoDB delete failed'
return NextResponse.json({ error: errorMessage }, { status: 500 })
}
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/dynamodb/get/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ export async function POST(request: NextRequest) {
item: result.item,
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage = error instanceof Error ? error.message : 'DynamoDB get failed'
return NextResponse.json({ error: errorMessage }, { status: 500 })
}
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/dynamodb/put/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export async function POST(request: NextRequest) {
item: validatedData.item,
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage = error instanceof Error ? error.message : 'DynamoDB put failed'
return NextResponse.json({ error: errorMessage }, { status: 500 })
}
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/dynamodb/query/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export async function POST(request: NextRequest) {
count: result.count,
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage = error instanceof Error ? error.message : 'DynamoDB query failed'
return NextResponse.json({ error: errorMessage }, { status: 500 })
}
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/dynamodb/scan/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export async function POST(request: NextRequest) {
count: result.count,
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage = error instanceof Error ? error.message : 'DynamoDB scan failed'
return NextResponse.json({ error: errorMessage }, { status: 500 })
}
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/dynamodb/update/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ export async function POST(request: NextRequest) {
item: result.attributes,
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
const errorMessage = error instanceof Error ? error.message : 'DynamoDB update failed'
return NextResponse.json({ error: errorMessage }, { status: 500 })
}
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/google_drive/download/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
logger.error(`[${requestId}] Error downloading Google Drive file:`, error)
return NextResponse.json(
{
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/app/api/tools/onedrive/download/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ export async function POST(request: NextRequest) {
},
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: error.errors[0]?.message ?? 'Invalid request' },
{ status: 400 }
)
}
logger.error(`[${requestId}] Error downloading OneDrive file:`, error)
return NextResponse.json(
{
Expand Down
Loading
Loading