Skip to content

Commit f3eb66f

Browse files
committed
Fix unsafe error handling in edge functions, add lint to CI
- Edge functions used err.message without checking err type, which throws if the caught value is not an Error object - Add lint step to CI pipeline before build
1 parent c224e76 commit f3eb66f

3 files changed

Lines changed: 3 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ jobs:
1616
node-version: 20
1717
cache: npm
1818
- run: npm ci
19+
- run: npm run lint
1920
- run: npm run build
2021
- run: npm test

supabase/functions/process-response/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Please review urgently.
141141
} catch (err) {
142142
console.error("process-response error:", err);
143143
return new Response(
144-
JSON.stringify({ error: err.message }),
144+
JSON.stringify({ error: err instanceof Error ? err.message : String(err) }),
145145
{ status: 500, headers: { ...corsHeaders, "Content-Type": "application/json" } }
146146
);
147147
}

supabase/functions/trigger-followup/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ If this is a medical emergency call 999.
115115
} catch (err) {
116116
console.error("trigger-followup error:", err);
117117
return new Response(
118-
JSON.stringify({ error: err.message }),
118+
JSON.stringify({ error: err instanceof Error ? err.message : String(err) }),
119119
{ status: 500, headers: { ...corsHeaders, "Content-Type": "application/json" } }
120120
);
121121
}

0 commit comments

Comments
 (0)