Validate that `parent_name` refers to an existing role (built-in or custom) and that adopting it as `child_name`'s parent does not create a cycle or exceed `MAX_ROLE_INHERITANCE_DEPTH`. Shared by `prepare_role` and `create_role` so both catalog mutation paths enforce the same rules.
(
child_name: &str,
parent_name: &str,
roles: &HashMap<String, CustomRole>,
)
| 380 | /// cycle or exceed `MAX_ROLE_INHERITANCE_DEPTH`. Shared by `prepare_role` |
| 381 | /// and `create_role` so both catalog mutation paths enforce the same rules. |
| 382 | fn validate_parent( |
| 383 | child_name: &str, |
| 384 | parent_name: &str, |
| 385 | roles: &HashMap<String, CustomRole>, |
| 386 | ) -> crate::Result<()> { |
| 387 | if !is_builtin(parent_name) && !roles.contains_key(parent_name) { |
| 388 | return Err(crate::Error::BadRequest { |
| 389 | detail: format!("parent role '{parent_name}' does not exist"), |
| 390 | }); |
| 391 | } |
| 392 | check_inheritance_chain(child_name, parent_name, roles) |
| 393 | } |
| 394 | |
| 395 | fn is_builtin(name: &str) -> bool { |
| 396 | matches!( |
no test coverage detected