SIGN IN SIGN UP

fix: Handle duplicate name in flows batch create with 409 response (#14634)

fix(api): return clean 409 on duplicate name in flows batch create

POST /flows/batch/ builds rows directly instead of routing through
_new_flow, so a UNIQUE(user_id, name)/(user_id, endpoint_name) collision
reaches session.flush() unhandled. Left un-rolled-back on SQLite, the
failed INSERT pins the write lock and the next writer busy-waits
busy_timeout (30s) before its own "database is locked"; the raw error
also leaks the SQL statement and bound parameters.

Roll back on IntegrityError to release the lock immediately and map the
violation to a 409 via _handle_unique_constraint_error (matching
upsert_flow). Add a regression test asserting 409, no leak, and a usable
session afterward.

Co-authored-by: Janardan S Kavia <janardanskavia@Janardans-MacBook-Pro.local>
J
Janardan Singh Kavia committed
54b71467309e4034606e90b29d98841a4bae844c
Parent: 13bb21c
Committed by GitHub <noreply@github.com> on 8/18/2026, 11:08:02 PM