Problem/Motivation

A migrate attempt in Drupal 11 ended up in a Type Error. I'm fairly certain all "Usage" steps have been followed, please see details in the Reproduce section below. Please advise, thank you.

[error]  TypeError: Drupal\migrate_file_to_media\Commands\MediaMigrateCommands::isLocalUri(): Argument #1 ($uri) must be of type string, null given, called in /var/www/html/web/modules/contrib/migrate_file_to_media/src/Commands/MediaMigrateCommands.php on line 336 in Drupal\migrate_file_to_media\Commands\MediaMigrateCommands->isLocalUri() (line 602 of /var/www/html/web/modules/contrib/migrate_file_to_media/src/Commands/MediaMigrateCommands.php) #0 /var/www/html/web/modules/contrib/migrate_file_to_media/src/Commands/MediaMigrateCommands.php(336): Drupal\migrate_file_to_media\Commands\MediaMigrateCommands->isLocalUri()
#1 [internal function]: Drupal\migrate_file_to_media\Commands\MediaMigrateCommands->duplicateFileDetection()
#2 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array()
#3 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
#4 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(175): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
#5 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(387): Consolidation\AnnotatedCommand\CommandProcessor->process()
#6 /var/www/html/vendor/symfony/console/Command/Command.php(279): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
#7 /var/www/html/vendor/symfony/console/Application.php(1094): Symfony\Component\Console\Command\Command->run()
#8 /var/www/html/vendor/symfony/console/Application.php(342): Symfony\Component\Console\Application->doRunCommand()
#9 /var/www/html/vendor/symfony/console/Application.php(193): Symfony\Component\Console\Application->doRun()
#10 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run()
#11 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
#12 /var/www/html/vendor/drush/drush/drush.php(140): Drush\Runtime\Runtime->run()
#13 /var/www/html/vendor/bin/drush.php(119): include('...')
#14 {main}. 

Steps to reproduce

ddev drush migrate:file-media-fields node downloads file file
Creating media reference fields for node : downloads.
Found field: field_download
Found existing media field: field_download_media
Created media field: field_download_media.
Clearing caches.

ddev drush generate mf2m_media
Module machine name:
➤ nmm
Plugin ID [Example]:
➤ nmm
Migration Group [media]:
➤ media
Entity Type [node]:
➤ node
Source Bundle:
➤ downloads
Source Field Names (comma separated) [field_image]:
➤ field_download
Target Media Type [image]:
➤ file
Target Media Type Field [field_media_image]:
➤ field_download_media
Language Code [en]:

Translation languages (comma separated) [none]:

Include field migration for all content revisions [no]:

Use migration file as a migration "plugin" or as "config" [plugin]:

The following directories and files have been created or updated:
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
• /var/www/html/web/modules/nmm/migrations/migrate_plus.migration.nmm_step1.yml
• /var/www/html/web/modules/nmm/migrations/migrate_plus.migration.nmm_step2.yml

ddev drush ms
media nmm_step1 Idle 0 0 0 0
(media)
media nmm_step2 Idle 77 0 77 0
(media)

ddev drush migrate:duplicate-file-detection nmm_step2
[error] TypeError: Drupal\migrate_file_to_media\Commands\MediaMigrateCommands::isLocalUri()

ddev drush migrate:duplicate-file-detection nmm_step1
[error] TypeError: Drupal\migrate_file_to_media\Commands\MediaMigrateCommands::isLocalUri()

CommentFileSizeAuthor
#2 fix-fatal-on-local-uri-null-3504916.patch732 bytesbekro
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

yurg created an issue. See original summary.

bekro’s picture

StatusFileSize
new732 bytes

Hello there,

I experienced the same issue and created a small quick and dirty patch which worked for me.

Greetings, bekro

hitchshock’s picture

Title: TypeError: Drupal\migrate_file_to_media\Commands\MediaMigrateCommands::isLocalUri(): Argument #1 ($uri) must be of type string, null given » Migration error
hitchshock’s picture

Priority: Normal » Critical

hitchshock’s picture

Status: Active » Fixed

@bekro thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.