Archive labels: Prevent policy error for admin labels
What does this MR do and why?
Archive labels: Prevent policy error for admin labels
The :admin_label policy is only defined for GroupLabels and ProjectLabels
For Admin Labels, an internal server occured since the policy is missing:
Internal server error: no policy for Label
This MR fixes this issue by checking the type.
References
How to set up and validate locally
- Enable feature flag via
rails c:
Feature.enable(:labels_archive, :instance)
- Create an admin label.
- Try to update this admin label before and after applying this MR. Before, you should get the above erorr, afterwards you should get
Label is not a project or group label.
curl --request POST \
--url https://gdk.test:3443/api/graphql \
--header 'Authorization: Bearer <PAT>' \
--header 'Content-Type: application/json' \
--data '{
"query": "mutation labelUpdate($id: LabelID!, $archived: Boolean) {\n labelUpdate(input: { id: $id, archived: $archived }) {\n label {\n id\n\t\t\tarchived\n }\n errors\n }\n}\n",
"operationName": "labelUpdate",
"variables": {
"id": "gid://gitlab/Label/<ADMIN LABEL ID>",
"archived": true
}
}'
MR acceptance checklist
MR Checklist ( @nwittstruck)
- Changelog entry added, if necessary
- Documentation created/updated via this MR
- Documentation reviewed by technical writer or follow-up review issue created
- Tests added for this feature/bug
- Tested in all supported browsers
- Conforms to the code review guidelines
- Conforms to the merge request performance guidelines
- Conforms to the style guides
- Conforms to the javascript style guides
- Conforms to the database guides
Related to #4233
Edited by Nicholas Wittstruck