-
Notifications
You must be signed in to change notification settings - Fork 733
fix: security results update (IN-1093) #4029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -78,10 +78,12 @@ export async function addEvaluationSuite( | |||||||||||||
| ($(id), $(name), $(repo), $(insightsProjectId), $(insightsProjectSlug), $(catalogId), $(result), $(corruptedState), now(), now()) | ||||||||||||||
| on conflict ("repo", "catalogId") | ||||||||||||||
| do update | ||||||||||||||
| set "updatedAt" = EXCLUDED."updatedAt", | ||||||||||||||
| "name" = EXCLUDED."name", | ||||||||||||||
| "result" = EXCLUDED."result", | ||||||||||||||
| "corruptedState" = EXCLUDED."corruptedState" | ||||||||||||||
| set "updatedAt" = EXCLUDED."updatedAt", | ||||||||||||||
| "name" = EXCLUDED."name", | ||||||||||||||
| "result" = EXCLUDED."result", | ||||||||||||||
| "corruptedState" = EXCLUDED."corruptedState", | ||||||||||||||
| "insightsProjectId" = EXCLUDED."insightsProjectId", | ||||||||||||||
| "insightsProjectSlug" = EXCLUDED."insightsProjectSlug" | ||||||||||||||
| `, | ||||||||||||||
| { | ||||||||||||||
| id: generateUUIDv4(), | ||||||||||||||
|
|
@@ -154,13 +156,15 @@ export async function addSuiteControlEvaluation( | |||||||||||||
| ) | ||||||||||||||
| on conflict ("securityInsightsEvaluationSuiteId", "repo", "controlId") | ||||||||||||||
| do update | ||||||||||||||
| set | ||||||||||||||
| "updatedAt" = EXCLUDED."updatedAt", | ||||||||||||||
| "name" = EXCLUDED."name", | ||||||||||||||
| "result" = EXCLUDED."result", | ||||||||||||||
| "message" = EXCLUDED."message", | ||||||||||||||
| "corruptedState" = EXCLUDED."corruptedState", | ||||||||||||||
| "remediationGuide" = EXCLUDED."remediationGuide" | ||||||||||||||
| set | ||||||||||||||
| "updatedAt" = EXCLUDED."updatedAt", | ||||||||||||||
| "name" = EXCLUDED."name", | ||||||||||||||
| "result" = EXCLUDED."result", | ||||||||||||||
| "message" = EXCLUDED."message", | ||||||||||||||
| "corruptedState" = EXCLUDED."corruptedState", | ||||||||||||||
| "remediationGuide" = EXCLUDED."remediationGuide", | ||||||||||||||
| "insightsProjectId" = EXCLUDED."insightsProjectId", | ||||||||||||||
| "insightsProjectSlug" = EXCLUDED."insightsProjectSlug" | ||||||||||||||
|
||||||||||||||
| "insightsProjectSlug" = EXCLUDED."insightsProjectSlug" | |
| "insightsProjectSlug" = ( | |
| select "slug" | |
| from "insightsProjects" | |
| where "id" = EXCLUDED."insightsProjectId" | |
| ) |
Copilot
AI
Apr 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the other security insights tables, insightsProjectSlug has an FK to insightsProjects.slug with ON UPDATE CASCADE. Updating it from EXCLUDED during the upsert can fail if the caller’s slug is stale (after a rename) and may undo the cascaded value. Consider leaving insightsProjectSlug untouched on conflict, or deriving it from insightsProjectId/insightsProjects within the update clause to guarantee consistency.
| "insightsProjectId" = EXCLUDED."insightsProjectId", | |
| "insightsProjectSlug" = EXCLUDED."insightsProjectSlug" | |
| "insightsProjectId" = EXCLUDED."insightsProjectId" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insightsProjectSlughas a FK toinsightsProjects.slugwithON UPDATE CASCADE(seebackend/src/database/migrations/V1753457861__add_unique_contraint_on_insights_slug.sql). Updating the slug fromEXCLUDEDduring the conflict update can cause the upsert to fail if the caller provides a stale slug (e.g., slug changed between read and write); previously the row would keep the cascaded/current slug. Consider not updatinginsightsProjectSlugon conflict, or deriving it frominsightsProjectId/insightsProjectsinside the update so it always remains valid/current.