gip-inclusion / immersion-facile

Service public numérique 🇫🇷 qui a pour objectif de faciliter les immersions professionnelles
https://immersion-facile.beta.gouv.fr
MIT License
14 stars 4 forks source link

Investigation erreur PG notification email recipients #1152

Closed celineung closed 9 months ago

celineung commented 10 months ago

Signalement de Benjamin: ça fait un bon moment qu'on a ce genre d'erreur en prod

code: "23502"
column: "email"
constraint: undefined
dataType: undefined
detail: "Failing row contains (d8c8826e-f8f0-49bf-9ae2-4fb482b226f1, null, to)."
file: "execMain.c"
hint: undefined
internalPosition: undefined
internalQuery: undefined
length: 284
line: "1883"
message: "null value in column \"email\" of relation \"notifications_email_recipients\" violates not-null constraint"
name: "error"
position: undefined
routine: "ExecConstraints"
schema: "public"
severity: "ERROR"
stack: "error: null value in column \"email\" of relation \"notifications_email_recipients\" violates not-null constraint\n    at /app/node_modules/.pnpm/pg@8.11.1/node_modules/pg/lib/client.js:526:17\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async PostgresConnection.executeQuery (/app/node_modules/.pnpm/kysely@0.26.3/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:72:28)\n    at async /app/node_modules/.pnpm/kysely@0.26.3/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28\n    at async #run (/app/node_modules/.pnpm/kysely@0.26.3/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)\n    at PostgresConnection.executeQuery (/app/node_modules/.pnpm/kysely@0.26.3/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:91:69)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async /app/node_modules/.pnpm/kysely@0.26.3/node_modules/kysely/dist/cjs/query-executor/query-executor-base.js:37:28\n    at async #run (/app/node_modules/.pnpm/kysely@0.26.3/node_modules/kysely/dist/cjs/driver/single-connection-provider.js:27:16)"
table: "notifications_email_recipients"
where: undefined

Lien discussion Discord: https://discord.com/channels/864451835553513474/1197882716113338409

celineung commented 9 months ago

Provient du cron triggerSuggestEditFormEstablishmentEvery6Months. On a en DB des establishments sans contacs:

SELECT io.siret, ic.email
FROM immersion_offers AS io
LEFT JOIN establishments AS e ON e.siret = io.siret
LEFT JOIN establishments__immersion_contacts AS eic ON e.siret = eic.establishment_siret
LEFT JOIN immersion_contacts AS ic ON eic.contact_uuid = ic.uuid
WHERE ic.email is null;

Image