elgentos / masquerade

Faker-driven, configuration-based, platform-agnostic, locale-compatible data faker tool
MIT License
236 stars 42 forks source link

Exceptions are not caught in the configuration context #110

Open michalrostek opened 1 year ago

michalrostek commented 1 year ago

Prerequisites:

Prerequisites of config 1):

admin #without ":" at the end
    admin_user:
        columns:
            lastname:

Actual (good) result of 1):

$ php masquerade.phar run --group admin

In Parser.php line 457:

  Unable to parse at line 1 (near "admin").  

run [--config [CONFIG]] [--platform [PLATFORM]] [--driver [DRIVER]] [--database [DATABASE]] [--username [USERNAME]] [--password [PASSWORD]] [--port [PORT]] [--host [HOST]] [--prefix [PREFIX]] [--locale [LOCALE]] [--group [GROUP]] [--charset [CHARSET]] [--with-integrity] [--batch-size BATCH-SIZE] [--working-dir [WORKING-DIR]]

Prerequisites of config 2):

admin:
    admin_user #without ":" at the end
        columns:
            lastname:

Actual (badly) result (same as in #109) of 2):

$ php masquerade.phar run --group admin
[Foreign key constraint checking is off - deletions will not affect linked tables]

._ _  _. _ _.    _ .__. _| _
| | |(_|_>(_||_|(/_|(_|(_|(/_
            |
                   by elgentos
                        v1.2.2
PHP Warning:  foreach() argument must be of type array|object, string given in phar:///var/www/magento/masquerade.phar/src/Elgentos/Masquerade/Console/RunCommand.php on line 131

Warning: foreach() argument must be of type array|object, string given in phar:///var/www/magento/masquerade.phar/src/Elgentos/Masquerade/Console/RunCommand.php on line 131
Anonymization complete in [0:0:0]

Prerequisites of config 3):

admin:
    admin_user:
        columns #without ":" at the end
            lastname:

Actual (badly) result of 3):

$ php masquerade.phar run --group admin
[Foreign key constraint checking is off - deletions will not affect linked tables]

._ _  _. _ _.    _ .__. _| _
| | |(_|_>(_||_|(/_|(_|(_|(/_
            |
                   by elgentos
                        v1.2.2
PHP Fatal error:  Uncaught TypeError: Cannot access offset of type string on string in phar:///var/www/magento/masquerade.phar/src/Elgentos/Masquerade/Console/RunCommand.php:132
Stack trace:
#0 phar:///var/www/magento/masquerade.phar/vendor/symfony/console/Command/Command.php(298): Elgentos\Masquerade\Console\RunCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 phar:///var/www/magento/masquerade.phar/vendor/symfony/console/Application.php(1005): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 phar:///var/www/magento/masquerade.phar/vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application->doRunCommand(Object(Elgentos\Masquerade\Console\RunCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 phar:///var/www/magento/masquerade.phar/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 phar:///var/www/magento/masquerade.phar/src/Elgentos/Masquerade/Application.php(14): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 phar:///var/www/magento/masquerade.phar/bin/masquerade(25): Elgentos\Masquerade\Application->run()
#6 /var/www/magento/masquerade.phar(14): require('phar:///var/www...')
#7 {main}
  thrown in phar:///var/www/magento/masquerade.phar/src/Elgentos/Masquerade/Console/RunCommand.php on line 132

Prerequisites of config 4):

admin:
    admin_user:
        columns:
            lastname #without ":" at the end

Actual (badly) result of 4):

$ php masquerade.phar run --group admin
[Foreign key constraint checking is off - deletions will not affect linked tables]

._ _  _. _ _.    _ .__. _| _
| | |(_|_>(_||_|(/_|(_|(_|(/_
            |
                   by elgentos
                        v1.2.2
PHP Warning:  foreach() argument must be of type array|object, string given in phar:///var/www/magento/masquerade.phar/src/Elgentos/Masquerade/DataProcessor/DefaultDataProcessorFactory.php on line 28

Warning: foreach() argument must be of type array|object, string given in phar:///var/www/magento/masquerade.phar/src/Elgentos/Masquerade/DataProcessor/DefaultDataProcessorFactory.php on line 28
[04-Apr-2023 10:50:29 UTC] PHP Fatal error:  Uncaught TypeError: Elgentos\Masquerade\DataProcessor\TableService::filterColumns(): Argument #1 ($inputColumns) must be of type array, string given, called in phar:///var/www/magento/masquerade.phar/src/Elgentos/Masquerade/DataProcessor/RegularTableProcessor.php on line 82 and defined in phar:///var/www/magento/masquerade.phar/src/Elgentos/Masquerade/DataProcessor/TableService.php:168
Stack trace:
#0 phar:///var/www/magento/masquerade.phar/src/Elgentos/Masquerade/DataProcessor/RegularTableProcessor.php(82): Elgentos\Masquerade\DataProcessor\TableService->filterColumns('lastname')
#1 phar:///var/www/magento/masquerade.phar/src/Elgentos/Masquerade/DataProcessor/RegularTableProcessor.php(64): Elgentos\Masquerade\DataProcessor\RegularTableProcessor->configuredColumns()
#2 phar:///var/www/magento/masquerade.phar/src/Elgentos/Masquerade/Console/RunCommand.php(209): Elgentos\Masquerade\DataProcessor\RegularTableProcessor->updateTable(500, Object(Closure))
#3 phar:///var/www/magento/masquerade.phar/src/Elgentos/Masquerade/Console/RunCommand.php(133): Elgentos\Masquerade\Console\RunCommand->fakeData(Array)
#4 phar:///var/www/magento/masquerade.phar/vendor/symfony/console/Command/Command.php(298): Elgentos\Masquerade\Console\RunCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 phar:///var/www/magento/masquerade.phar/vendor/symfony/console/Application.php(1005): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 phar:///var/www/magento/masquerade.phar/vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application->doRunCommand(Object(Elgentos\Masquerade\Console\RunCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 phar:///var/www/magento/masquerade.phar/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 phar:///var/www/magento/masquerade.phar/src/Elgentos/Masquerade/Application.php(14): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 phar:///var/www/magento/masquerade.phar/bin/masquerade(25): Elgentos\Masquerade\Application->run()
#10 /var/www/magento/masquerade.phar(14): require('phar:///var/www...')
#11 {main}
  thrown in phar:///var/www/magento/masquerade.phar/src/Elgentos/Masquerade/DataProcessor/TableService.php on line 168
peterjaap commented 1 year ago

Thanks for your report! We're open to a PR to improve this experience :)