4

I started getting this error running bin/magento setup:di:compile:

Invalid ExtensionInterface for nonexistent class Interface in file /bitnami/magento/htdocs/app/code/Magento/TestModuleExtensionAttributes/Api/Data/FakeExtensibleTwoInterface.php

Deleting the generated/ and var/ folders did not help, nor did emptying the cache and re-indexing. Has anyone encountered a problem like this?

4 Answers 4

6

I believe that you try to run the test on this installation. And test copy test modules in app/code folder and do not remove it.

Please delete app/code/Magento/Test* modules manually and re run compilation

2
6

I found that specifying Magento\Framework\Api\ExtensionAttributesInterface and the methods getExtensionAttributes & setExtensionAttributes in my Repository class:

namespace MY\MODULE\Api\Data;

use Magento\Framework\{
    Api\ExtensibleDataInterface,
    Api\ExtensionAttributesInterface,
    Model\ResourceModel\Db\AbstractDb
};

/** @api */
interface MyModelInterface extends ExtensibleDataInterface
{
   ......

   /** @return ExtensionAttributesInterface */
   public function getExtensionAttributes(): ExtensionAttributesInterface;

   /** 
    * @param ExtensionAttributesInterface 
    * @return CatalogProductIndexPriceLogModelInterface
    */
   public function setExtensionAttributes(ExtensionAttributesInterface $extensionAttributes): CatalogProductIndexPriceLogModelInterface;

Was causing:

php bin/magento setup:di:compile
Compilation was started.
Interception cache generation... 6/7 [========================>---]  85% 36 secs 476.0 MiBErrors during configuration scanning:
    ExtensionAttributesInterface
        Invalid ExtensionInterface for nonexistent class ExtensionAInterface in file /home/www/projects/magento2/the-block-shop/src/app/code/Convert/MonitorIndexers/Api/Data/CatalogProductIndexPriceLogModelInterface.php
Total Errors Count: 1

Removing these from the my interface but keeping them in my concrete class then running:

rm -rf generated/ && php bin/magento setup:di:compile

Worked.

4
  • you just saved me from hours of hair-pulling :)
    – aeno
    Sep 16, 2020 at 12:03
  • Great! That's exactly what I want to do here! :) Sep 16, 2020 at 22:37
  • @ChrisRogers any clue why this was not working
    – Zahirabbas
    Jul 6, 2021 at 12:51
  • Not too sure why but, perhaps it has something to do with either: Not formatting phpdoc correctly (/** @api */) or that I/we might be specifying strict type return values! Magento ay!! Jul 6, 2021 at 23:50
2

Full path need to be set. See my case:

enter image description here

0

enter image description here

/**
 * Retrieve existing extension attributes object or create a new one.
 *
 * @return \YourVendor\YourModule\Api\Data\YourModelExtensionInterface|null
 */
  public function getExtensionAttributes();

/**
 * Set an extension attributes object.
 *
 * @param \YourVendor\YourModule\Api\Data\YourModelExtensionInterface $extensionAttributes
 * @return $this
 */
  public function setExtensionAttributes(
    \YourVendor\YourModule\Api\Data\YourModelExtensionInterface $extensionAttributes
  ): self;

for me it worked with full path

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.