diff --git a/bundle/permissions/permission_report.go b/bundle/permissions/permission_report.go index c9e4281ee..a9468edb6 100644 --- a/bundle/permissions/permission_report.go +++ b/bundle/permissions/permission_report.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/log" ) @@ -16,9 +17,9 @@ import ( func ReportPossiblePermissionDenied(ctx context.Context, b *bundle.Bundle, path string) diag.Diagnostics { log.Errorf(ctx, "Failed to update, encountered possible permission error: %v", path) - user := b.Config.Workspace.CurrentUser.DisplayName - if user == "" { - user = b.Config.Workspace.CurrentUser.UserName + user := b.Config.Workspace.CurrentUser.UserName + if auth.IsServicePrincipal(user) { + user = b.Config.Workspace.CurrentUser.DisplayName } canManageBundle, assistance := analyzeBundlePermissions(b) diff --git a/bundle/permissions/permission_report_test.go b/bundle/permissions/permission_report_test.go index b92637bc7..61592f7e5 100644 --- a/bundle/permissions/permission_report_test.go +++ b/bundle/permissions/permission_report_test.go @@ -15,7 +15,7 @@ func TestPermissionsReportPermissionDeniedWithGroup(t *testing.T) { }) diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath") - expected := "EPERM3: unable to deploy to testpath as Test User. Cannot apply local deployment permissions.\n" + + expected := "EPERM3: unable to deploy to testpath as testuser@databricks.com. Cannot apply local deployment permissions.\n" + "For assistance, contact the owners of this project.\n" + "They can redeploy the project to apply the latest set of permissions.\n" + "Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions." @@ -28,7 +28,7 @@ func TestPermissionsReportPermissionDeniedWithOtherGroup(t *testing.T) { }) diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath") - expected := "EPERM1: unable to deploy to testpath as Test User.\n" + + expected := "EPERM1: unable to deploy to testpath as testuser@databricks.com.\n" + "Please make sure the current user or one of their groups is listed under the permissions of this bundle.\n" + "For assistance, users or groups with appropriate permissions may include: othergroup.\n" + "They may need to redeploy the bundle to apply the new permissions.\n" + @@ -42,7 +42,7 @@ func TestPermissionsReportPermissionDeniedWithoutPermission(t *testing.T) { }) diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath") - expected := "EPERM1: unable to deploy to testpath as Test User.\n" + + expected := "EPERM1: unable to deploy to testpath as testuser@databricks.com.\n" + "Please make sure the current user or one of their groups is listed under the permissions of this bundle.\n" + "For assistance, contact the owners of this project.\n" + "They may need to redeploy the bundle to apply the new permissions.\n" + @@ -54,7 +54,7 @@ func TestPermissionsReportPermissionDeniedNilPermission(t *testing.T) { b := mockBundle(nil) diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath") - expected := "EPERM1: unable to deploy to testpath as Test User.\n" + + expected := "EPERM1: unable to deploy to testpath as testuser@databricks.com.\n" + "Please make sure the current user or one of their groups is listed under the permissions of this bundle.\n" + "For assistance, contact the owners of this project.\n" + "They may need to redeploy the bundle to apply the new permissions.\n" + @@ -69,7 +69,7 @@ func TestPermissionsReportFindOtherOwners(t *testing.T) { }) diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath") - require.ErrorContains(t, diags.Error(), "EPERM3: unable to deploy to testpath as Test User. Cannot apply local deployment permissions.\n"+ + require.ErrorContains(t, diags.Error(), "EPERM3: unable to deploy to testpath as testuser@databricks.com. Cannot apply local deployment permissions.\n"+ "For assistance, users or groups with appropriate permissions may include: alice@databricks.com.\n"+ "They can redeploy the project to apply the latest set of permissions.\n"+ "Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions.")