From bf6be656bd6cfaf549d3179be5a6bd551cad4f01 Mon Sep 17 00:00:00 2001 From: luciano Date: Thu, 7 May 2026 15:44:41 +0200 Subject: [PATCH] debug(check-in): log upsert + verify lettura post-write Diagnostica temporanea: la POST /me/check-ins ritorna 201 ma il record non appare in DB. Aggiunto log prima/dopo upsert + rilettura immediata per individuare se il middleware prisma-field-encryption rollba silenziosamente. --- apps/api/src/modules/tracking/check-in.routes.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/api/src/modules/tracking/check-in.routes.ts b/apps/api/src/modules/tracking/check-in.routes.ts index 19b4605..66905d5 100644 --- a/apps/api/src/modules/tracking/check-in.routes.ts +++ b/apps/api/src/modules/tracking/check-in.routes.ts @@ -68,6 +68,7 @@ export const checkInRoutes: FastifyPluginAsync = async (fastify) => { const date = new Date(data.date); date.setHours(0, 0, 0, 0); + request.log.info({ userId, date, body: data }, '[check-in] upsert START'); const item = await fastify.prisma.dailyCheckIn.upsert({ where: { userId_date: { userId, date } }, create: { @@ -87,6 +88,13 @@ export const checkInRoutes: FastifyPluginAsync = async (fastify) => { notes: data.notes ?? null, }, }); + request.log.info({ id: item.id }, '[check-in] upsert OK'); + // Rilettura immediata per verificare che il record sia effettivamente + // persistito (catch silent rollback da middleware encryption). + const verify = await fastify.prisma.dailyCheckIn.findUnique({ + where: { userId_date: { userId, date } }, + }); + request.log.info({ found: verify != null, verifyId: verify?.id }, '[check-in] verify'); return reply.code(201).send({ item: { id: item.id } }); },