Search code examples
installationmodulemagento2upgradeamqp

Error on magento setup:upgrade - Element 'route': Missing child element(s). Expected is ( resources )


I'm using Magento 2.4.1 (Community) installed locally on Windows.

This is what I get when running php bin/magento setup:upgade

Module 'Magento_Amqp':
Invalid Document
Element 'route': Missing child element(s). Expected is ( resources ).
Line: 11

Element 'route': Missing child element(s). Expected is ( resources ).
Line: 15

Element 'route': Missing child element(s). Expected is ( resources ).
Line: 11

Element 'route': Missing child element(s). Expected is ( resources ).
Line: 15

Everything was working fine, then I added a new module for a new payment method (after already having a sample one added and running). It was installed successfully and showed in enabled modules but it didn't show in my admin panel. After trying all the commands for cache cleaning, flushing, reindexing, etc, I decided to run setup:di:compile and after some time when I was trying again setup:upgrade all of a sudden this error appeared. I can't even find such error text on Google. I tried disabling the Amqp module (I know it shoudn't be disabled, but for the test) and it showed the same error for Module 'Magento_MysqlMq'.

I'm really sick and tired of all the never-seen-before errors that keep coming every time I add new files to Magento modules. Would appreciate some help.


Solution

  • Turned out the error was about the etc/webapi.xml file in my modules. Probably I hadn't run setup:di:compile after adding the API routes and that's why it haven't showed up before that. After removing one of my modules it showed me where is the error. I had copied the files from the first to the new one, maybe because the error was in both of them it wasn't showing error location.

    However, I added

            <resources>
                <resource ref="anonymous"/>
            </resources>
    

    in all my routes in webapi.xml and the error disappeared. (These routes have worked well all the time, but this is Magento...)