Fix error when querying custom attributes on non-existing attributable
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you receive complimentary access to GitLab Duo.
What does this MR do and why?
Querying custom attributes on project, group or user caused a 500.
This MR fixes this behaviour and returns a 404 instead.
References
How to set up and validate locally
Before applying the MR the following requests should cause a 500, afterwards a 404. The suggested URL assumes there is no user with the specified id. The same applies to projects and groups.
- List all custom attributes:
curl --request GET \
--url https://gdk.test:3443/api/v4/users/10000/custom_attributes \
--header 'Authorization: Bearer <glpat-...>'
- List specific existing custom attribute:
curl --request GET \
--url https://gdk.test:3443/api/v4/users/10000/custom_attributes/my-custom-location \
--header 'Authorization: Bearer <glpat-...>'
- Create/Update a specific custom attribute:
curl --request PUT \
--url https://gdk.test:3443/api/v4/users/100000/custom_attributes/my-custom-location \
--header 'Authorization: Bearer <glpat-....>' \
--header 'Content-Type: application/json' \
--data '{"value": "example"}'
MR acceptance checklist
checklist
-
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
Edited by Nicholas Wittstruck