-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
azurerm_role_management_policy
- Fix interface conversion panic
#26800
Conversation
Thank you @xuzhang3 for making this fix. In addition, Is it possible to add a test case to cover this business flow in this PR for I'm impressed that this bug was not caught was because there was no test coverage, or, is there already a test case covering this flow while that test case has been failed due to this crash bug? |
sure , working on it. |
@mybayern1974 tests added and all tests passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @xuzhang3, this fixes the current crash but we should take it one step further to prevent potential future panics
@@ -267,7 +267,9 @@ func buildRoleManagementPolicyForUpdate(metadata *sdk.ResourceMetaData, rolePoli | |||
} | |||
} else { | |||
if approvalStagesRaw, ok := settings["approvalStages"]; ok { | |||
approvalStages = approvalStagesRaw.([]map[string]interface{}) | |||
for _, stage := range approvalStagesRaw.([]interface{}) { | |||
approvalStages = append(approvalStages, stage.(map[string]interface{})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check that stage
is a map[string]interface{}
before casting to it to prevent another potential crash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type assertions added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @xuzhang3 LGTM 👍
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Community Note
Description
Fix interface conversion panice.
PR Checklist
For example: “
resource_name_here
- description of change e.g. adding propertynew_property_name_here
”Changes to existing Resource / Data Source
Testing
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_resource
- support for thething1
property [GH-00000]This is a (please select all that apply):
Related Issue(s)
Fixes #26567
Note
If this PR changes meaningfully during the course of review please update the title and description as required.