Kentico/xperience-by-kentico-kentico-migration-tool

Media migration fail for non admin privilege users

liamgold opened this issue · 4 comments

Brief bug description

When migrating a KX13 database, that contains users that no longer have Editor/Administrator/Global Administrator role, these users are not migrated to XbyK as admin users.

However, when this happens, if a media file was uploaded to the media library by that user, the migration process will fail to continue as the user has not been migrated to XbyK.

Error message:

11:11:54.520 info: Migration.Toolkit.Core.KX13.Behaviors.XbKApiContextBehavior[0] Using CMSActionContext of user 'administrator'
11:11:54.565 fail: Migration.Toolkit.Core.KX13.Mappers.MediaFileInfoMapper[0] NeedManualAction: False, ReferenceName: MediaFileIsMissingOnSourceFilesystem, AdditionalInfo: FileId: 447, FilePath: 00d48177-31cb-ee11-a834-000d3ada2c7b.png, FileGuid: afea09e8-4121-4676-92f8-90d20cbce82a, FileLibraryId: 1, FileSiteId: 1
11:11:54.573 warn: Migration.Toolkit.Core.KX13.Services.KeyLocatorService[0] Mapping Migration.Toolkit.KX13.Models.CmsUser primary key: 5788 failed, Sequence contains no elements
11:11:54.576 warn: Migration.Toolkit.Core.KX13.Services.KeyLocatorService[0] Mapping Migration.Toolkit.KX13.Models.CmsUser primary key: 5788 failed, Sequence contains no elements
11:11:54.577 fail: Migration.Toolkit.Core.KX13.Mappers.MediaFileInfoMapper[0] NeedManualAction: True, ReferenceName: MissingRequiredDependency, AdditionalInfo: DependencyType: CmsUser, FieldName: UserId, SourceValue: 5788
11:11:54.577 fail: Migration.Toolkit.Core.KX13.Mappers.MediaFileInfoMapper[0] NeedManualAction: True, ReferenceName: MissingRequiredDependency, AdditionalInfo: DependencyType: CmsUser, FieldName: UserId, SourceValue: 5788

Giving this user administrator privilege level "fixes" it, but there's a reason the user doesn't have those permission levels anymore.

Repro steps

  1. Create a KX13 site/db
  2. Upload an image to media library with a test user with Administrator privilege level
  3. Change that test user to None privilege level
  4. Run migrate toolkit, and you get the error.

Expected behavior

Ideally I would want the migration to associate any failed migration files with the default administrator account, if the original user is not migrated.

In my example scenario, there's ~30 user IDs being reported in the logs that no longer have access to admin roles. Ideally I don't want to go through changing their permissions on the old KX13 database, JUST to migrate media files to the new XbyK site, I would be happy with them being associated to the admin account.

I assume the same would happen if the user was deleted or disabled in KX13 too.

@liamgold i shall define fallback user loaded from configuration with default 'administrator' - this user will be used on all media files where user was converted to member (or lost admin privileges from any reason). Did i understood issue correctly and does solution work for You?

Yes that sounds perfect.

Always migrate the media file, and just fallback to the default administrator account if the original user doesn't exist/have permission.

I got around this by running a SQL query locally to give the users Administrator privilege level, but ideally I wouldn't be doing this as the user would then be imported into XbyK as an administrator.

@liamgold it will not be always, there are still valid circumstances when migration of media file should fail - for example when admin user is not migrated due to failure (that would result in unwanted transfer of ownership from valid editor/admin).

But i accept use case where valid owner no longer exists (for example owner is now only member or lost admin access)

@liamgold issue should be fixed with recent release, closing