Problem/Motivation

In our case we have 1,000 URLs and for a subset of these there is no value present in the markup. What we then get is an InvalidArgumentException with the following error for every odd URL of the list:

The current node list is empty

See the Crawler class:

...
    public function link(string $method = 'get'): Link
    {
        if (!$this->nodes) {
            throw new \InvalidArgumentException('The current node list is empty.');
        }

Steps to reproduce

Have a migrate setup with large sets of URLs, having a few odd rows w/o a value for a XPath selector. The migration will fail on the first error and halt.

Proposed resolution

I see we're using the same InvalidArgumentException class as used within Crawler class, but perhaps we could create a different class to distinguish amongst those?
Then we can still halt the migration on faulty usage of the migrate source plugin but are able to catch the Crawler error and emit a warning for the failing URLs.

Remaining tasks

1. Create a different Exception class for supported filter types within the migrate source plugin
2. Catch and log the Crawler's "The current node list is empty" error but continue migration process
3. Review and test change

User interface changes

N/A

API changes

N/A

Data model changes

N/A

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

baikho created an issue. See original summary.

baikho’s picture

Issue summary: View changes

  • 34084c9d committed on issue-3505532
    #3505532 Distinguish 'The current node list is empty'...

  • 0da75764 committed on issue-3505532
    #3505532 Distinguish 'The current node list is empty'...

  • 4e6708e0 committed on 1.0.x
    #3505532 Distinguish 'The current node list is empty'...

  • 4747ab41 committed on 1.0.x
    #3505532 Distinguish 'The current node list is empty'...

  • b160c0e6 committed on issue-3505532
    #3505532 Distinguish 'The current node list is empty'...

  • 4e6708e0 committed on issue-3505532
    #3505532 Distinguish 'The current node list is empty'...

  • reinchek committed a274f038 on 1.0.x
    #3505532 Distinguish 'The current node list is empty'...
reinchek’s picture

Hi @baikho, there's now a new custom exception, called PluginErrorException designed to handle plugin configurations errors. Furthermore i've added a try catch around main for loop to catch and log InvalidArgumentException errors, in this way the migration doesn't stop.
Everything is included in the new release 1.0.1.

Thanks ;)

reinchek’s picture

Status: Active » Reviewed & tested by the community
reinchek’s picture

Status: Reviewed & tested by the community » Fixed
reinchek’s picture

Version: 1.0.x-dev » 1.0.1
baikho’s picture

#10 Great stuff, many thanks!

Status: Fixed » Closed (fixed)

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