Magento2: Missing method in webapi.xml results in fatal error on setup:upgrade

Created on 29 Dec 2019  路  5Comments  路  Source: magento/magento2


Magento: 2.3.3

Summary (*)

  1. Create a custom module with a webapi.xml and add a route URL. For Example:
 <route url="/V1/mymodule/myurl" method="GET">
        <service class="MyVendor\MyModule\Api\MyRepositoryInterface" method="getMyContent"/>
    </route>
  1. Create a repository interface and class MyVendor\MyModule\Api\MyRepositoryInterface but do not add the method getMyContent in any.

  2. Run php bin/magento setup:di:compile and results success.

  3. Run php bin/magento setup:upgrade and results fatal error as below.

Notice: Undefined index: create in /magento-root/vendor/magento/framework/Reflection/MethodsMap.php on line 83

Examples (*)


same as above.

Proposed solution


The below method does not check if the index is available or throws any exception to debug.

https://github.com/magento/magento2/blob/6159dc859b8e5ed4b1baa7348befaca5b3f15335/lib/internal/Magento/Framework/Reflection/MethodsMap.php#L79-L82

I would suggest throwing an Exception with the interface name and function that is missing. which will really help in debugging the error.

Format is valid

All 5 comments

Hi @milindsingh. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [x] Summary of the issue
  • [x] Information on your environment
  • [x] Steps to reproduce
  • [x] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

@milindsingh do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [x] yes
  • [ ] no

Hi @milindsingh thanks for your issue, I'll check it. Are you using production mode, aren't you?

Thanks @marcoaacoliveira
I am on developer mode still, I think the same will happen on production mode too.

@milindsingh I couldn't reproduced it neither on Magento 2.3.2 nor 2.4 (in setup:upgrade step, I don't have a clean instance of Magento 2.3.3 right now so I didn't try on it), but when I tried to access swagger I got strange errors (that doesn't mean anything). I think it would be a good improvement throws exceptions in this case.

Thanks @marcoaacoliveira I have tried in 2.4-develop but unable to reproduce. So closing it for now.

Was this page helpful?
0 / 5 - 0 ratings