Skip to content

Conversation

@matt-FFFFFF
Copy link
Member

@matt-FFFFFF matt-FFFFFF commented Jan 9, 2026

This pull request improves the robustness and test coverage of policy role assignment generation in the deployment hierarchy. The main changes involve better error handling to ensure that valid role assignments are still returned even when some errors occur, and the addition of comprehensive tests to verify this behavior.

Error Handling Improvements:

  • Modified Hierarchy.PolicyRoleAssignments to accumulate PolicyRoleAssignmentErrors and continue processing, but to immediately return on non-PolicyRoleAssignmentErrors, ensuring partial results are only returned for known, aggregatable errors.
  • Updated HierarchyManagementGroup.generatePolicyAssignmentAdditionalRoleAssignments to skip policy definitions with no role definition IDs instead of returning an error, preventing unnecessary failures and allowing processing to continue. [1] [2]

Testing Enhancements:

  • Added a comprehensive test suite to hierarchy_test.go for PolicyRoleAssignments, covering scenarios with partial errors, all-success cases, and non-aggregatable errors, ensuring correct behavior and error reporting in all situations.

fixes Azure/Azure-Landing-Zones#3973

Add tests for PolicyRoleAssignments func covering:
- Valid role assignments returned even when PolicyRoleAssignmentErrors occurs
- All role assignments returned when no errors occur
- Non-PolicyRoleAssignmentErrors error returns nil results
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.99%. Comparing base (11971db) to head (a3027c5).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
deployment/managementgroup.go 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #234      +/-   ##
==========================================
+ Coverage   50.52%   51.99%   +1.46%     
==========================================
  Files          49       49              
  Lines        3968     3964       -4     
==========================================
+ Hits         2005     2061      +56     
+ Misses       1701     1645      -56     
+ Partials      262      258       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@matt-FFFFFF matt-FFFFFF added this pull request to the merge queue Jan 9, 2026
Merged via the queue into main with commit c828d22 Jan 9, 2026
7 checks passed
@matt-FFFFFF matt-FFFFFF deleted the fix/policyRoleAssignment branch January 9, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[alzlib]: PolicyRoleAssignments should not discard result if there are PolicyRoleAssignmentErrors

4 participants