-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Copy link
Labels
Description
Summary
When creating a control with malformed payload, the server returned 422, but a control still got created with empty data in the database.
Motivation
This causes UI issues because empty controls are later loaded and fail validation.
Current behavior
Empty controls can still get created.
Expected behavior
A 422 from a write endpoint should not result in any write.
Reproduction (if bug)
- send a create-with-definition request
- the request returns
422 - a control is still present in the database with empty data
Verified root cause
For a create-with-definition flow, the client did:
PUT /api/v1/controlswith justname- the server inserted an empty shell control
PUT /api/v1/controls/{id}/datawith the definition- if step 3 returned
422, the empty shell from step 2 was still in the DB
That is the actual server-side bug. The association between agent and empty control was caller-flow dependent, but the root problem was that invalid create requests were not atomic.
Proposed solution (optional)
Validate the definition before inserting anything, so failed create requests do not persist shell controls.
Additional context
Fixed by PR #139.
Reactions are currently unavailable