Supervisory Node create endpoint does not validate unique code but returns sql constraint error


We need to add unique code validation for adding supervisory nodes.

Now when user tries to create a new supervisory node using API (there is no edit/add page for Supervisory Nodes) and enters duplicated code he/she gets sql exception. Instead we need to introduce validation for code uniqueness and return human-readable validation error message.




Ben Leibert
November 6, 2017, 10:13 PM

The following response body is now returned in lieu of an exception:

Although this is much better, I'm under the impression that the message property should be more descriptive.

and : Although I'm not sure how you'd prioritize the above improvement, I failed the test run of OLMIS-3552.

Sam Im
November 7, 2017, 12:06 AM

, Please change the error message to say: "This Supervisory Node code already exists." Then the user should be directed back to the Create Supervisory Node page, so they can edit the supervisory node code.

Joanna Bebak
November 7, 2017, 9:45 AM

I tested the ticket, and now everything works correctly. Please only add the changelog.

Joanna Bebak
November 7, 2017, 11:05 AM

The changelog was added, so I will close the ticket.

Josh Zamor
November 7, 2017, 9:41 PM

I double/triple checked this ticket and agree that it can be considered done.

However the implementation of this ticket is not fully correct:

  • I pushed a small bit of code that covers the actual handling of the database exception - which this ticket /should/ have done.

  • I created a new issue, OLMIS-3570, to migrate away from the current inadequate Validation technique being used throughout this Service

Functionally, the normal user paths were fixed. However the root cause, handling the exception that arises from a DB constraint was not, even though that was pointed out in the comments here. As I wrote in OLMIS-3570, using Validation java code, for what is inherently a DB constraint logic, isn't appropriate (violates DRY) nor accurate (Validation Java code relies on transaction isolation level).


Nikodem Graczewski


Mateusz Kwiatkowski

Story Points


Time tracking


Time remaining





Fix versions