File tree Expand file tree Collapse file tree
services/apps/merge_suggestions_worker/src/activities Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -498,10 +498,22 @@ export async function removeOrganizationMergeSuggestions(
498498
499499export async function addOrganizationSuggestionToNoMerge ( suggestion : string [ ] ) : Promise < void > {
500500 if ( suggestion . length !== 2 ) {
501- svc . log . debug ( ` Suggestions array must have two ids!` )
501+ svc . log . debug ( ' Suggestions array must have exactly two ids!' )
502502 return
503503 }
504+
504505 const qx = pgpQx ( svc . postgres . writer . connection ( ) )
505506
506- await addOrgNoMerge ( qx , suggestion [ 0 ] , suggestion [ 1 ] )
507+ try {
508+ await addOrgNoMerge ( qx , suggestion [ 0 ] , suggestion [ 1 ] )
509+ } catch ( error : unknown ) {
510+ // Handle foreign key constraint violation gracefully
511+ if ( error instanceof Error && 'code' in error && error . code === '23503' ) {
512+ svc . log . info ( { suggestion } , 'Foreign key constraint violation, skipping no merge!' )
513+ return
514+ }
515+
516+ svc . log . error ( { error, suggestion } , 'Error adding organization suggestion to no merge!' )
517+ throw error
518+ }
507519}
You can’t perform that action at this time.
0 commit comments