Fix error when querying custom attributes on non-existing attributable

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.

🛠️ with ❤️ at Siemens

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.

  1. List all custom attributes:
curl --request GET \
  --url https://gdk.test:3443/api/v4/users/10000/custom_attributes \
  --header 'Authorization: Bearer <glpat-...>'
  1. 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-...>'
  1. 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
Edited by Nicholas Wittstruck

Merge request reports

Loading