A new module version deployed to production caused a 500 error across the whole shop. DI compilation ended with an error about a missing interface. The problem was a constructor signature change without updating di.xml. Fix time: 1 hour.
Symptoms
- 500 error across the whole shop after deployment
bin/magento setup:di:compileends with an error- In logs:
Argument X passed to Constructor must implement interface Y
Cause
A constructor signature change – adding a new dependency – without regenerating DI compiled code. On staging compilation ran automatically, on production the deployment skipped this step.
Solution
rm -rf generated/code generated/metadata bin/magento setup:di:compile
#!/bin/bash set -e composer install --no-dev --optimize-autoloader bin/magento maintenance:enable bin/magento setup:upgrade --keep-generated bin/magento setup:di:compile bin/magento setup:static-content:deploy -f pl_PL en_US bin/magento cache:flush bin/magento maintenance:disable
Takeaways
DI compilation must be part of every deployment pipeline. Use the set -e flag in deployment scripts – if compilation fails, the deployment stops instead of deploying broken code. Test on staging with the same script as on production.
