Skip to content

Commit d9ec6cd

Browse files
apeabodyNA2047
authored andcommitted
fix: handle responses without policies (GoogleCloudPlatform#13280)
1 parent 63be525 commit d9ec6cd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mmv1/third_party/terraform/services/accesscontextmanager/data_source_access_context_manager_access_policy.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func dataSourceAccessContextManagerAccessPolicyRead(d *schema.ResourceData, meta
7575

7676
policies, err := parse_policies_response(res)
7777
if err != nil {
78-
fmt.Errorf("Error parsing list policies response: %s", err)
78+
return fmt.Errorf("Error parsing list policies response: %s", err)
7979
}
8080

8181
// Find the matching policy in the list of policies response. Both the parent and scopes
@@ -102,6 +102,11 @@ func dataSourceAccessContextManagerAccessPolicyRead(d *schema.ResourceData, meta
102102

103103
func parse_policies_response(res map[string]interface{}) ([]AccessPolicy, error) {
104104
var policies []AccessPolicy
105+
if _, ok := res["accessPolicies"].([]interface{}); !ok {
106+
// response did not include any policies
107+
return policies, nil
108+
}
109+
105110
for _, res_policy := range res["accessPolicies"].([]interface{}) {
106111
parsed_policy := &AccessPolicy{}
107112

0 commit comments

Comments
 (0)