@@ -164,6 +164,19 @@ func resourceTencentCloudIdentityCenterRoleAssignmentCreate(d *schema.ResourceDa
164164
165165 if len (response .Response .Tasks ) > 0 {
166166 task := response .Response .Tasks [0 ]
167+ if task == nil {
168+ return fmt .Errorf ("task is nil" )
169+ }
170+ if task .Status != nil && * task .Status == "Failed" {
171+ if task .FailureReason != nil {
172+ return fmt .Errorf ("CreateRoleAssignment failed, failure reason:%s" , * task .FailureReason )
173+ }
174+ return fmt .Errorf ("CreateRoleAssignment failed" )
175+ }
176+
177+ if task .TaskId == nil {
178+ return fmt .Errorf ("task id is nil" )
179+ }
167180 taskId := * task .TaskId
168181 roleConfigurationId := * task .RoleConfigurationId
169182 conf := tccommon .BuildStateChangeConf ([]string {}, []string {"Success" }, 2 * tccommon .ReadRetryTimeout , time .Second , service .AssignmentTaskStatusStateRefreshFunc (zoneId , taskId , []string {}))
@@ -292,8 +305,21 @@ func resourceTencentCloudIdentityCenterRoleAssignmentDelete(d *schema.ResourceDa
292305 return err
293306 }
294307
295- if deleteRoleAssignmentResponse .Response != nil && deleteRoleAssignmentResponse .Response .Task != nil && deleteRoleAssignmentResponse .Response .Task .TaskId != nil {
296- conf := tccommon .BuildStateChangeConf ([]string {}, []string {"Success" }, 2 * tccommon .ReadRetryTimeout , time .Second , service .AssignmentTaskStatusStateRefreshFunc (zoneId , * deleteRoleAssignmentResponse .Response .Task .TaskId , []string {}))
308+ if deleteRoleAssignmentResponse == nil || deleteRoleAssignmentResponse .Response == nil {
309+ return fmt .Errorf ("delete role assignment response is nil" )
310+ }
311+ if deleteRoleAssignmentResponse .Response .Task == nil {
312+ return fmt .Errorf ("delete role assignment task is nil" )
313+ }
314+ task := deleteRoleAssignmentResponse .Response .Task
315+ if task .Status != nil && * task .Status == "Failed" {
316+ if task .FailureReason != nil {
317+ return fmt .Errorf ("DeleteRoleAssignment failed, failure reason:%s" , * task .FailureReason )
318+ }
319+ return fmt .Errorf ("DeleteRoleAssignment failed" )
320+ }
321+ if task .TaskId != nil {
322+ conf := tccommon .BuildStateChangeConf ([]string {}, []string {"Success" }, 2 * tccommon .ReadRetryTimeout , time .Second , service .AssignmentTaskStatusStateRefreshFunc (zoneId , * task .TaskId , []string {}))
297323 if _ , e := conf .WaitForState (); e != nil {
298324 return e
299325 }
0 commit comments