Open-source Formbricks fixes partial database writes in AI demo response generator
A developer auditing Formbricks, an open-source survey platform, discovered that its AI example-response generator could partially commit data to the database even when the operation reported a failure. The bug caused some records—such as tags and display entries—to be written before a response creation error rolled back only part of the transaction, leaving the database in an inconsistent state. Initial attempts to wrap the entire operation in a single outer transaction triggered a deadlock due to Prisma's connection pool constraints, forcing a redesign of the fix. The final solution separates the external model call from the database transaction, then acquires a FOR NO KEY UPDATE lock on the survey row before validating ownership, archive status, and response count, ensuring all synthetic entities are written atomically. The patch also enforces strict error propagation for quota-link failures so that no partial batch can silently persist during example generation.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in