fix: add ::uuid casts to all agent_sessions queries

PostgreSQL can't implicitly coerce text params to UUID columns.
Add explicit ::uuid casts on id and project_id in all agent session
routes (list, get, patch, stop, approve).

Made-with: Cursor
This commit is contained in:
2026-03-07 11:49:40 -08:00
parent 18f61fe95c
commit f7d38317b2
4 changed files with 11 additions and 11 deletions

View File

@@ -44,7 +44,7 @@ export async function POST(
const rows = await query<{ data: Record<string, unknown> }>(
`SELECT p.data FROM fs_projects p
JOIN fs_users u ON u.id = p.user_id
WHERE p.id = $1 AND u.data->>'email' = $2 LIMIT 1`,
WHERE p.id = $1::uuid AND u.data->>'email' = $2 LIMIT 1`,
[projectId, session.user.email]
);
if (rows.length === 0) {
@@ -59,7 +59,7 @@ export async function POST(
// Find the session to get the appName (so we can find the right Coolify UUID)
const sessionRows = await query<{ app_name: string; status: string }>(
`SELECT app_name, status FROM agent_sessions WHERE id = $1 AND project_id = $2 LIMIT 1`,
`SELECT app_name, status FROM agent_sessions WHERE id = $1::uuid AND project_id = $2::uuid LIMIT 1`,
[sessionId, projectId]
);
if (sessionRows.length === 0) {
@@ -109,7 +109,7 @@ export async function POST(
`UPDATE agent_sessions
SET status = 'approved', completed_at = COALESCE(completed_at, now()), updated_at = now(),
output = output || $1::jsonb
WHERE id = $2`,
WHERE id = $2::uuid`,
[
JSON.stringify([{
ts: new Date().toISOString(),