Skip to content

Commit

Permalink
Fix a crash in security policy
Browse files Browse the repository at this point in the history
handleReadError swallows error in case of 404 response, so its
not suitable as safeguard against returned object having nil value.

Signed-off-by: Anna Khmelnitsky <akhmelnitsky@vmware.com>
  • Loading branch information
annakhm committed May 1, 2024
1 parent e76412f commit a80a94f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_parent_security_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func parentSecurityPolicyModelToSchema(d *schema.ResourceData, m interface{}) (*
client := domains.NewSecurityPoliciesClient(getSessionContext(d, m), connector)
obj, err := client.Get(domainName, id)
if err != nil {
return nil, handleReadError(d, "SecurityPolicy", id, err)
return nil, err
}
d.Set("display_name", obj.DisplayName)
d.Set("description", obj.Description)
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_security_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func resourceNsxtPolicySecurityPolicyGeneralCreate(d *schema.ResourceData, m int
func resourceNsxtPolicySecurityPolicyGeneralRead(d *schema.ResourceData, m interface{}, withRule bool) error {
obj, err := parentSecurityPolicyModelToSchema(d, m)
if err != nil {
return err
return handleReadError(d, "SecurityPolicy", d.Id(), err)
}
if withRule {
return setPolicyRulesInSchema(d, obj.Rules)
Expand Down

0 comments on commit a80a94f

Please sign in to comment.