@@ -565,10 +565,24 @@ func (r *PermissionResource) ImportState(ctx context.Context, req resource.Impor
565565 configuredValue := permID
566566 resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root (mapping .GetField ()), types .StringValue (configuredValue ))... )
567567
568- // Set principal fields
569- resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("user_name" ), types .StringValue (userName ))... )
570- resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("group_name" ), types .StringValue (groupName ))... )
571- resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("service_principal_name" ), types .StringValue (servicePrincipalName ))... )
568+ // Set principal fields - use null for empty strings to avoid ImportStateVerify failures
569+ if userName != "" {
570+ resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("user_name" ), types .StringValue (userName ))... )
571+ } else {
572+ resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("user_name" ), types .StringNull ())... )
573+ }
574+
575+ if groupName != "" {
576+ resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("group_name" ), types .StringValue (groupName ))... )
577+ } else {
578+ resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("group_name" ), types .StringNull ())... )
579+ }
580+
581+ if servicePrincipalName != "" {
582+ resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("service_principal_name" ), types .StringValue (servicePrincipalName ))... )
583+ } else {
584+ resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("service_principal_name" ), types .StringNull ())... )
585+ }
572586
573587 // Set permission level
574588 resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root ("permission_level" ), types .StringValue (permissionLevel ))... )
0 commit comments