Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountering a TypeError exception when running a bake migration_diff #803

Open
cnizzardini opened this issue Jan 11, 2025 · 1 comment
Open
Assignees
Labels

Comments

@cnizzardini
Copy link
Contributor

cnizzardini commented Jan 11, 2025

Description

Encountering a type error when running a bake migration_diff. Hopefully this isn't user error. Additional versions that may be useful:

  • cakephp/bake: 3.1.1
  • robmorgan/phinx: 0.16.6
  • cakephp/migrations: 4.2.0 (i upgraded this all the way to 4.5 and the problem persisted).

Further, I also ran composer update -W and the problem persisted.

Steps to reproduce:

Run bin/cake bake migration_diff UserRateLimit with the following MySQL schema:

CREATE TABLE `user_rate_limits` (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` varchar(32) DEFAULT NULL,
  `ip_address` varchar(64) NOT NULL,
  `limit_type` enum('per_day','per_minute','auth') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

Expected

Migration class to be created

Actual Result:

Sorry for this horrendous stacktrace:

2025-01-10 22:06:58 warning: Undefined array key "precision"
Trace:
Migrations\View\Helper\MigrationHelper->getColumnOption() /srv/app/vendor/twig/twig/src/Extension/CoreExtension.php, line 1871
Twig\Extension\CoreExtension::getAttribute() /srv/app/vendor/twig/twig/src/Environment.php(407) : eval()'d code, line 166
__TwigTemplate_4c6b09aa2ff857341f1f31f07630396a->doDisplay() /srv/app/vendor/twig/twig/src/Template.php, line 387
Twig\Template->yield() /srv/app/vendor/twig/twig/src/Template.php, line 343
Twig\Template->display() /srv/app/vendor/twig/twig/src/Template.php, line 358
Twig\Template->render() /srv/app/vendor/twig/twig/src/TemplateWrapper.php, line 51
Twig\TemplateWrapper->render() /srv/app/vendor/cakephp/twig-view/src/View/TwigView.php, line 299
Cake\TwigView\View\TwigView->_evaluate() /srv/app/vendor/cakephp/cakephp/src/View/View.php, line 1145
Cake\View\View->_render() /srv/app/vendor/cakephp/bake/src/View/BakeView.php, line 91
Bake\View\BakeView->render() /srv/app/vendor/cakephp/bake/src/Utility/TemplateRenderer.php, line 101
Bake\Utility\TemplateRenderer->generate() /srv/app/vendor/cakephp/migrations/src/Command/BakeSimpleMigrationCommand.php, line 129
Migrations\Command\BakeSimpleMigrationCommand->bake() /srv/app/vendor/cakephp/migrations/src/Command/BakeMigrationDiffCommand.php, line 139
Migrations\Command\BakeMigrationDiffCommand->bake() /srv/app/vendor/cakephp/migrations/src/Command/BakeSimpleMigrationCommand.php, line 92
Migrations\Command\BakeSimpleMigrationCommand->execute() /srv/app/vendor/cakephp/cakephp/src/Console/BaseCommand.php, line 192
Cake\Console\BaseCommand->run() /srv/app/vendor/cakephp/cakephp/src/Console/CommandRunner.php, line 327
Cake\Console\CommandRunner->runCommand() /srv/app/vendor/cakephp/cakephp/src/Console/CommandRunner.php, line 168
Cake\Console\CommandRunner->run() /srv/app/bin/cake.php, line 12
[main]

warning: 2 :: Undefined array key "precision" on line 415 of /srv/app/vendor/cakephp/migrations/src/View/Helper/MigrationHelper.php
Stack Trace:

Migrations\View\Helper\MigrationHelper->getColumnOption() /srv/app/vendor/twig/twig/src/Extension/CoreExtension.php, line 1871
Twig\Extension\CoreExtension::getAttribute() /srv/app/vendor/twig/twig/src/Environment.php(407) : eval()'d code, line 166
__TwigTemplate_4c6b09aa2ff857341f1f31f07630396a->doDisplay() /srv/app/vendor/twig/twig/src/Template.php, line 387
Twig\Template->yield() /srv/app/vendor/twig/twig/src/Template.php, line 343
Twig\Template->display() /srv/app/vendor/twig/twig/src/Template.php, line 358
Twig\Template->render() /srv/app/vendor/twig/twig/src/TemplateWrapper.php, line 51
Twig\TemplateWrapper->render() /srv/app/vendor/cakephp/twig-view/src/View/TwigView.php, line 299
Cake\TwigView\View\TwigView->_evaluate() /srv/app/vendor/cakephp/cakephp/src/View/View.php, line 1145
Cake\View\View->_render() /srv/app/vendor/cakephp/bake/src/View/BakeView.php, line 91
Bake\View\BakeView->render() /srv/app/vendor/cakephp/bake/src/Utility/TemplateRenderer.php, line 101
Bake\Utility\TemplateRenderer->generate() /srv/app/vendor/cakephp/migrations/src/Command/BakeSimpleMigrationCommand.php, line 129
Migrations\Command\BakeSimpleMigrationCommand->bake() /srv/app/vendor/cakephp/migrations/src/Command/BakeMigrationDiffCommand.php, line 139
Migrations\Command\BakeMigrationDiffCommand->bake() /srv/app/vendor/cakephp/migrations/src/Command/BakeSimpleMigrationCommand.php, line 92
Migrations\Command\BakeSimpleMigrationCommand->execute() /srv/app/vendor/cakephp/cakephp/src/Console/BaseCommand.php, line 192
Cake\Console\BaseCommand->run() /srv/app/vendor/cakephp/cakephp/src/Console/CommandRunner.php, line 327
Cake\Console\CommandRunner->runCommand() /srv/app/vendor/cakephp/cakephp/src/Console/CommandRunner.php, line 168
Cake\Console\CommandRunner->run() /srv/app/bin/cake.php, line 12
[main]
Xdebug: [Step Debug] Could not connect to debugging client. Tried: 172.17.0.1:9003 (fallback through xdebug.client_host/xdebug.client_port).
2025-01-10 22:06:58 error: [Twig\Error\RuntimeError] An exception has been thrown during the rendering of a template ("Migrations\View\Helper\MigrationHelper::formatConstraintAction(): Argument cakephp/cakephp#1 ($constraint) must be of type string, null given, called in /srv/app/vendor/twig/twig/src/Extension/CoreExtension.php on line 1871"). in /srv/app/vendor/cakephp/migrations/templates/bake/element/add-foreign-keys.twig on line 30
Stack Trace:
- /srv/app/vendor/twig/twig/src/Template.php:343
- /srv/app/vendor/twig/twig/src/Template.php:358
- /srv/app/vendor/twig/twig/src/TemplateWrapper.php:51
- /srv/app/vendor/cakephp/twig-view/src/View/TwigView.php:299
- /srv/app/vendor/cakephp/cakephp/src/View/View.php:1145
- /srv/app/vendor/cakephp/cakephp/src/View/View.php:1689
- /srv/app/vendor/cakephp/cakephp/src/View/View.php:676
- /srv/app/vendor/cakephp/migrations/src/View/Helper/MigrationHelper.php:651
- /srv/app/vendor/twig/twig/src/Extension/CoreExtension.php:1871
- /srv/app/vendor/twig/twig/src/Environment.php(407) : eval()'d code:240
- /srv/app/vendor/twig/twig/src/Template.php:387
- /srv/app/vendor/twig/twig/src/Template.php:343
- /srv/app/vendor/twig/twig/src/Template.php:358
- /srv/app/vendor/twig/twig/src/TemplateWrapper.php:51
- /srv/app/vendor/cakephp/twig-view/src/View/TwigView.php:299
- /srv/app/vendor/cakephp/cakephp/src/View/View.php:1145
- /srv/app/vendor/cakephp/bake/src/View/BakeView.php:91
- /srv/app/vendor/cakephp/bake/src/Utility/TemplateRenderer.php:101
- /srv/app/vendor/cakephp/migrations/src/Command/BakeSimpleMigrationCommand.php:129
- /srv/app/vendor/cakephp/migrations/src/Command/BakeMigrationDiffCommand.php:139
- /srv/app/vendor/cakephp/migrations/src/Command/BakeSimpleMigrationCommand.php:92
- /srv/app/vendor/cakephp/cakephp/src/Console/BaseCommand.php:192
- /srv/app/vendor/cakephp/cakephp/src/Console/CommandRunner.php:327
- /srv/app/vendor/cakephp/cakephp/src/Console/CommandRunner.php:168
- /srv/app/bin/cake.php:12
- [main]:

Caused by: [TypeError] Migrations\View\Helper\MigrationHelper::formatConstraintAction(): Argument cakephp/cakephp#1 ($constraint) must be of type string, null given, called in /srv/app/vendor/twig/twig/src/Extension/CoreExtension.php on line 1871 in /srv/app/vendor/cakephp/migrations/src/View/Helper/MigrationHelper.php on line 261
Stack Trace:
- /srv/app/vendor/twig/twig/src/Extension/CoreExtension.php:1871
- /srv/app/vendor/twig/twig/src/Environment.php(407) : eval()'d code:109
- /srv/app/vendor/twig/twig/src/Template.php:387
- /srv/app/vendor/twig/twig/src/Template.php:343
- /srv/app/vendor/twig/twig/src/Template.php:358
- /srv/app/vendor/twig/twig/src/TemplateWrapper.php:51
- /srv/app/vendor/cakephp/twig-view/src/View/TwigView.php:299
- /srv/app/vendor/cakephp/cakephp/src/View/View.php:1145
- /srv/app/vendor/cakephp/cakephp/src/View/View.php:1689
- /srv/app/vendor/cakephp/cakephp/src/View/View.php:676
- /srv/app/vendor/cakephp/migrations/src/View/Helper/MigrationHelper.php:651
- /srv/app/vendor/twig/twig/src/Extension/CoreExtension.php:1871
- /srv/app/vendor/twig/twig/src/Environment.php(407) : eval()'d code:240
- /srv/app/vendor/twig/twig/src/Template.php:387
- /srv/app/vendor/twig/twig/src/Template.php:343
- /srv/app/vendor/twig/twig/src/Template.php:358
- /srv/app/vendor/twig/twig/src/TemplateWrapper.php:51
- /srv/app/vendor/cakephp/twig-view/src/View/TwigView.php:299
- /srv/app/vendor/cakephp/cakephp/src/View/View.php:1145
- /srv/app/vendor/cakephp/bake/src/View/BakeView.php:91
- /srv/app/vendor/cakephp/bake/src/Utility/TemplateRenderer.php:101
- /srv/app/vendor/cakephp/migrations/src/Command/BakeSimpleMigrationCommand.php:129
- /srv/app/vendor/cakephp/migrations/src/Command/BakeMigrationDiffCommand.php:139
- /srv/app/vendor/cakephp/migrations/src/Command/BakeSimpleMigrationCommand.php:92
- /srv/app/vendor/cakephp/cakephp/src/Console/BaseCommand.php:192
- /srv/app/vendor/cakephp/cakephp/src/Console/CommandRunner.php:327
- /srv/app/vendor/cakephp/cakephp/src/Console/CommandRunner.php:168
- /srv/app/bin/cake.php:12
- [main]:

[Twig\Error\RuntimeError] An exception has been thrown during the rendering of a template ("Migrations\View\Helper\MigrationHelper::formatConstraintAction(): Argument cakephp/cakephp#1 ($constraint) must be of type string, null given, called in /srv/app/vendor/twig/twig/src/Extension/CoreExtension.php on line 1871"). in /srv/app/vendor/cakephp/migrations/templates/bake/element/add-foreign-keys.twig on line 30

Stack Trace:

Twig\Template->yield() - ROOT/vendor/twig/twig/src/Template.php, line 343
Twig\Template->display() - ROOT/vendor/twig/twig/src/Template.php, line 358
Twig\Template->render() - ROOT/vendor/twig/twig/src/TemplateWrapper.php, line 51
Twig\TemplateWrapper->render() - ROOT/vendor/cakephp/twig-view/src/View/TwigView.php, line 299
Cake\TwigView\View\TwigView->_evaluate() - CORE/src/View/View.php, line 1145
Cake\View\View->_render() - CORE/src/View/View.php, line 1689
Cake\View\View->_renderElement() - CORE/src/View/View.php, line 676
Cake\View\View->element() - ROOT/vendor/cakephp/migrations/src/View/Helper/MigrationHelper.php, line 651
Migrations\View\Helper\MigrationHelper->element() - ROOT/vendor/twig/twig/src/Extension/CoreExtension.php, line 1871
Twig\Extension\CoreExtension::getAttribute() - ROOT/vendor/twig/twig/src/Environment.php(407) : eval()'d code, line 240
__TwigTemplate_4c6b09aa2ff857341f1f31f07630396a->doDisplay() - ROOT/vendor/twig/twig/src/Template.php, line 387
Twig\Template->yield() - ROOT/vendor/twig/twig/src/Template.php, line 343
Twig\Template->display() - ROOT/vendor/twig/twig/src/Template.php, line 358
Twig\Template->render() - ROOT/vendor/twig/twig/src/TemplateWrapper.php, line 51
Twig\TemplateWrapper->render() - ROOT/vendor/cakephp/twig-view/src/View/TwigView.php, line 299
Cake\TwigView\View\TwigView->_evaluate() - CORE/src/View/View.php, line 1145
Cake\View\View->_render() - ROOT/vendor/cakephp/bake/src/View/BakeView.php, line 91
Bake\View\BakeView->render() - ROOT/vendor/cakephp/bake/src/Utility/TemplateRenderer.php, line 101
Bake\Utility\TemplateRenderer->generate() - ROOT/vendor/cakephp/migrations/src/Command/BakeSimpleMigrationCommand.php, line 129
Migrations\Command\BakeSimpleMigrationCommand->bake() - ROOT/vendor/cakephp/migrations/src/Command/BakeMigrationDiffCommand.php, line 139
Migrations\Command\BakeMigrationDiffCommand->bake() - ROOT/vendor/cakephp/migrations/src/Command/BakeSimpleMigrationCommand.php, line 92
Migrations\Command\BakeSimpleMigrationCommand->execute() - CORE/src/Console/BaseCommand.php, line 192
Cake\Console\BaseCommand->run() - CORE/src/Console/CommandRunner.php, line 327
Cake\Console\CommandRunner->runCommand() - CORE/src/Console/CommandRunner.php, line 168
Cake\Console\CommandRunner->run() - ROOT/bin/cake.php, line 12
[main] - [main], line 0

Caused by [TypeError] Migrations\View\Helper\MigrationHelper::formatConstraintAction(): Argument cakephp/cakephp#1 ($constraint) must be of type string, null given, called in /srv/app/vendor/twig/twig/src/Extension/CoreExtension.php on line 1871 in /srv/app/vendor/cakephp/migrations/src/View/Helper/MigrationHelper.php on line 261

Stack Trace:

Migrations\View\Helper\MigrationHelper->formatConstraintAction() - ROOT/vendor/twig/twig/src/Extension/CoreExtension.php, line 1871
Twig\Extension\CoreExtension::getAttribute() - ROOT/vendor/twig/twig/src/Environment.php(407) : eval()'d code, line 109
__TwigTemplate_f249712c7740946c2b82eb62f96cd5d5->doDisplay() - ROOT/vendor/twig/twig/src/Template.php, line 387
[main] - [main], line 0

CakePHP Version

5.0.11

PHP Version

8.3

@cnizzardini cnizzardini changed the title Encountering a type error when running a bake migration_diff Encountering a TypeError exception when running a bake migration_diff Jan 11, 2025
@ADmad ADmad transferred this issue from cakephp/cakephp Jan 11, 2025
@markstory markstory added this to the 4.x (CakePHP 5) milestone Jan 16, 2025
@markstory markstory self-assigned this Jan 16, 2025
markstory added a commit that referenced this issue Jan 16, 2025
I wasn't able to reproduce this locally, perhaps it will error in CI
@markstory
Copy link
Member

I've tried to add this scenario as a test, hopefully the issue can reproduce in CI. I wasn't able to reproduce your issue when running this test locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants