[AAP-75240] Fix role_team_assignment content_type mismatch causing 4… - #192
[AAP-75240] Fix role_team_assignment content_type mismatch causing 4…#192rohitthakur2590 wants to merge 11 commits into
Conversation
…0/500 errors and enable resource-level type support Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>
Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>
Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>
Resolve conflicts in user.py and role_user_assignment.py by keeping stable-2.6 versions; the 75240 fix remains in role_team_assignment.py. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
CasC NotificationThis PR touches areas that may affect the CasC collections (e.g. infra.aap_configuration). Detected changes in CasC-monitored areas:
Please tag the CasC collections team in this PR so they are aware of the change.
|
Co-authored-by: Cursor <cursoragent@cursor.com>
CasC NotificationThis PR touches areas that may affect the CasC collections (e.g. infra.aap_configuration). Detected changes in CasC-monitored areas:
Please tag the CasC collections team in this PR so they are aware of the change.
|
…ts to verify all ep locally
CasC NotificationThis PR touches areas that may affect the CasC collections (e.g. infra.aap_configuration). Detected changes in CasC-monitored areas:
Please tag the CasC collections team in this PR so they are aware of the change.
|
CasC NotificationThis PR touches areas that may affect the CasC collections (e.g. infra.aap_configuration). Detected changes in CasC-monitored areas:
Please tag the CasC collections team in this PR so they are aware of the change.
|
CasC NotificationThis PR touches areas that may affect the CasC collections (e.g. infra.aap_configuration). Detected changes in CasC-monitored areas:
Please tag the CasC collections team in this PR so they are aware of the change.
|
|
DVCS PR Check Results: PR appears valid (JIRA key(s) found) |
…00/500 errors and enable resource-level type support
Description
Three changes in plugins/modules/role_team_assignment.py:
Replaced the hardcoded allowed type list in _validate_selector() , the old code only permitted type: organizations and type: teams in assignment_objects. It now accepts all resource-level types (projects, inventories, credentials, job_templates, activations, event_streams, decision_environments, and all Hub/Galaxy types) by deriving the allowed set dynamically from a new CONTENT_TYPE_ENDPOINT_MAP constant.
Added type-match validation , when a user provides type: in assignment_objects, the module now validates that it matches what the role definition's content_type actually expects. A mismatch produces a clear, actionable error message instead of a cryptic 400/500 from the Gateway API.
Changed the gate in main() from elif entity_type and object_param: to elif object_param: the block now runs whenever assignment_objects is provided, regardless of whether the role has a content_type. This also correctly handles the object_id and object_ansible_id paths within the loop.
The bug was introduced in v2.6.20260306 when the entity_type derivation changed from prefix-matching on the role name to reading content_type directly from the API response. This was architecturally correct but exposed two pre-existing problems:
Bug 1 (400/500): A role like "Launch User Role - Projects" has content_type = "awx.project". When combined with type: organizations in assignment_objects, the module correctly looked up the organization (id=42) but then sent that org ID as object_id for a role the Gateway API expects to point at a project. The API rejected it with 400 "Project matching query does not exist." or 500 Internal Server Error. Before v2.6.20260306 this was a silent no-op (nothing was assigned) because the old prefix-matching code set entity_type = None for non-"Team"/"Organization" role names, skipping the block entirely.
Bug 2 (blocked type): Even users who correctly knew they needed type: projects for a project-scoped role could not use it — the hardcoded allowed = ("organizations", "teams") rejected it immediately with "Unsupported type 'projects'". This made it impossible to assign any resource-level role by name without falling back to ansible.builtin.uri directly.
The fix validates the type combination before any API call is made
Type of Change
Self-Review Checklist
Testing Instructions
Prerequisites
Steps to Test
Expected Results
Additional Context
Required Actions
Screenshots/Logs