Problem statement
How can rules be reordered from within the Dashboard? The Dashboard throws an error when attempting to reorder the rules by dragging and dropping them. This error occurs after a rule is deleted, and an attempt is made to reorder the remaining rules.
Symptoms
- When trying to reorder the Rules using the drag & drop option, the Dashboard throws an error.
Steps to reproduce
- Create three rules named
Rule 1
,Rule 2
, andRule 3
through the management dashboard. - Delete
Rule 2
. - Create
Rule 4
. - Try and reorder
Rule 1
andRule 3
. - Observe the 500 error.
Troubleshooting
- Please confirm that you have deleted the Rule before trying to re-order the remaining Rules.
Cause
There is a mismatch between Dashboard and the Management API where the API
tries to PATCH /rules
with this payload when you do the re-order:
[
{ "rule_id": "abc", "name": "Rule 1", "order": 1 },
{ "rule_id": "def", "name": "Rule 3", "order": 2 },
{ "rule_id": "ghi", "name": "Rule 4", "order": 3 }
]
However, due to Rule 2 being deleted prior to the reorder, the data stored by the API is:
[
{ "rule_id": "abc", "name": "Rule 1", "order": 1 },
{ "rule_id": "def", "name": "Rule 3", "order": 3 },
{ "rule_id": "ghi", "name": "Rule 4", "order": 4 }
]
This inconsistency in how the orders are calculated causes an exception in the back-end.
Solution
To resolve this issue, manually reorder the rules by using the PATCH /rules
Management API endpoint.
To change from
Rule 1
→ Rule 3
→ Rule 4
to
Rule 1
→ Rule 4
→ Rule 3
,
make the following PATCH /rules
request:
{
{ "rule_id": "abc", "name": "Rule 1", "order": 1 },
{ "rule_id": "def", "name": "Rule 3", "order": 4 },
{ "rule_id": "ghi", "name": "Rule 4", "order": 3 }
}