]> git.openstreetmap.org Git - rails.git/commit
Don't save trace tags until the trace is saved
authorvignesh-chaturvedi <vigneshchaturvedi@gmail.com>
Thu, 15 Oct 2026 05:20:12 +0000 (05:20 +0000)
committervignesh-chaturvedi <vigneshchaturvedi@gmail.com>
Mon, 19 Oct 2026 15:45:12 +0000 (15:45 +0000)
commitfe5a25522cbbc237ae86806367162353283c24ea
treeabec49494f27827751a5d315ae2400d882dcf673
parent94974824e7a6dec2b823fa673a54761f66471f3d
Don't save trace tags until the trace is saved

Assigning a new set of tags to an existing trace saved them immediately,
so an invalid tag raised ActiveRecord::RecordNotSaved instead of failing
validation. The API returned a 500 error and the edit form showed an
error page.

Build the new tags instead so they are validated and saved along with
the trace, and update the trace through the API in a transaction so the
old tags are kept if the update fails.
app/controllers/api/traces_controller.rb
app/models/trace.rb
test/controllers/api/traces_controller_test.rb
test/controllers/traces_controller_test.rb
test/models/trace_test.rb