Add group name validation for subgroups
What does this MR do and why?
This MR intends to resolve the following bug: #346883 (closed)
An attempt to create a subgroup with the same name as an existing subgroup returns a 500 error.
Logs:
ActiveRecord::RecordNotUnique
PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_namespaces_name_parent_id_type"
DETAIL: Key (name, parent_id, type)=(SOMEGROUP, 111111, Group) already exists.
PG::UniqueViolation
ERROR: duplicate key value violates unique constraint "index_namespaces_name_parent_id_type"
It seems like, the unique index was modified in this MR: !71390 (merged). There are no validations in the group model.
The lookup is using index. However, I'm not sure about the performance impact as it's a group level validation(conditional).
> Group.where(name: "subgroup", parent_id: 33).explain
Index Scan using index_groups_on_parent_id_id on namespaces (cost=0.13..2.15 rows=1 width=379)
Index Cond: (parent_id = 33)
Filter: ((name)::text = 'subgroup'::text)
(3 rows)
Screenshots or screen recordings
Before:
After:
How to set up and validate locally
- Checkout this branch
- Create a group and a subgroup
- Create another subgroup with the same name
- Notice that the UI shows validation errors instead of 500 error
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by sameer shaik