Consent to the use of Personal Data and Cookies

This website needs your consent to use cookies in order to customize ads and content.

If you give us your consent, data may be shared with Google.

Return value of getLabel() must be of the type string

How to debug a problem in Shopware where getLabel() returns null instead of string.


By. Jacob

Edited: 2022-06-23 16:48

Return value of Shopware\Core\Framework\Plugin\PluginEntity::getLabel() must be of the type string, null returned

I recently had this error when running a plugin:list command for my local Shopware installation in Docker, the problem seem to happen if a plugin is not properly installed. In my case, Somehow I seem to have messed up my local installation.

Running plugin:refresh should fix the problem. E.g:

sudo -u www-data bin/console plugin:refresh


When running the command with the -vv option it tells us the specific file where the error occurred:

Shopware\Core\Framework\Plugin\PluginEntity->getLabel() at /srv/shopware/vendor/shopware/core/Framework/Plugin/Command/Lifecycle/AbstractPluginLifecycleCommand.php:230

This shows that the problem happens because the getLabel() method returnes null instead of the expected type, string.

To further debug the problem I tried wrapping it in a try .. catch block, filling out the label with the specific error message on problematic plugins. E.g.:

try {
 $pluginLabel = $plugin->getLabel();
} catch (\Throwable $th) {
 $pluginLabel = $th->getMessage();

Then I simply replaced $plugin->getLabel() with $pluginLabel where it was used.

Doing this finally allowed Shopware's plugin:list command to run, outputting the specific error message as label, if missing. But this was not very helpful to do, because I already knew what the error was; it did however send me down the right track in the debugging process, because I could see exactly which plugins had the problem.

Next I tried reading the composer.json file of the problematic plugins, but oddly, the label was not missing in the composer file, so this was clearly not the issue; this was then I realised something must have gone wrong in my Shopware installation.

The fix for the error turned out to be surprisingly simple; I just had to run a plugin:refresh command. Doing this somehow reintroduced or reloaded the plugin labels, and I was able to revert my changes to the core files.

Note. Obviously it is bad to change the core files, but it is totally fine to make temporary changes for debugging purposes.

With the console commmands, remember you can use echo, print and var_dump to show output in the terminal when running the command.

Tell us what you think:

  1. Things that might go wrong with Scheduled Tasks in Shopware.
  2. How to fix an error in Shopware that prevents displaying the frontpage: Unable to find a matching sales channel
  3. When updating Shopware, AclPermissionCollection may no longer exist, resulting in a clogged enqueue table and breaking the message workers.

More in: Shopware