Error Message is not useful when assigning same program to facility more than one time

Description

Steps

  1. Generate valid access_token. You need to have a permission to update facilities (you can use admin user)

  2. create a valid request body where you have two similar entries in supportedPrograms field:

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 { "operator":{ "code":"moh", "name":"Ministry of Health", "displayOrder":1, "id":"9456c3e9-c4a6-4a28-9e08-47ceb16a4121" }, "openLmisAccessible":true, "supportedPrograms":[ { "id":"10845cb9-d365-4aaa-badd-b4fa39c6a26a", "code":"PRG002", "name":"Essential Meds", "programActive":true, "periodsSkippable":false, "showNonFullSupplyTab":false, "supportActive":true, "supportLocallyFulfilled":false }, { "code":"PRG002", "name":"Essential Meds", "programActive":false, "periodsSkippable":false, "showNonFullSupplyTab":false, "supportActive":true, "supportLocallyFulfilled":false }, { "id":"dce17f2e-af3e-40ad-8e00-3496adef44c3", "code":"PRG001", "name":"Family Planning", "programActive":true, "periodsSkippable":true, "showNonFullSupplyTab":true, "supportActive":true, "supportLocallyFulfilled":false } ], "id":"e6799d64-d10d-4011-b8c2-0e4d4a3f65ce", "name":"Comfort Health Clinic", "code":"HC01", "active":true, "enabled":true, "type":{ "code":"health_center", "name":"Health Center", "displayOrder":2, "active":true, "id":"ac1d268b-ce10-455f-bf87-9c667da8f060" }, "geographicZone":{ "code":"Malawi-Southern-Neno", "name":"Neno District", "level":{ "code":"District", "levelNumber":3, "id":"93c05138-4550-4461-9e8a-79d5f050c223" }, "parent":{ "code":"Malawi-Southern", "name":"Southern Region", "level":{ "code":"Region", "levelNumber":2, "id":"9b497d87-cdd9-400e-bb04-fae0bf6a9491" }, "parent":{ "code":"Malawi", "name":"Malawi", "level":{ "code":"Country", "levelNumber":1, "id":"6b78e6c6-292e-4733-bb9c-3d802ad61206" }, "id":"4e471242-da63-436c-8157-ade3e615c848" }, "id":"0bbd69c1-e20f-48f5-aae4-26dcd8aa7602" }, "id":"4df0cc89-8a71-450f-9c1a-29ceea1f14f3" } }
  3. send request to update the facility

Expected result

  • error message that supportedProgram field contains incorrect value

Actual result

  • 400 response code

    1 2 3 4 { "messageKey": "could not execute statement; SQL [n/a]; constraint [uk_mnsci7u7h2r2b3tohhn0b819]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement", "message": "could not execute statement; SQL [n/a]; constraint [uk_mnsci7u7h2r2b3tohhn0b819]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement" }

Acceptance criteria

  • Block possibility to create/update a facility that support the given program more than one time

    • add a correct rename database constraint to be more meaningfull and assign it to proper message key in constraint map

  • User should get correct error message why facility could not be created/updated.

Environment

None

Status

Assignee

Adugna Worku

Reporter

Łukasz Lewczyński

Labels

None

Story Points

2

Epic Link

Components

Sprint

None

Fix versions

Affects versions

3.2.1

Priority

Minor