The "default_image" entity type does not exist

Created on 21 April 2024, 2 months ago
Updated 30 April 2024, about 2 months ago

Problem/Motivation

Getting Error on file usage page for default image uploaded on image field.

Steps to reproduce

  1. Upload and set default image for any field.
  2. Check the files in the admin/content/files page
  3. Click the file usage link for the file. the page getting 500 Error

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "default_image" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 139 of /app/docroot/core/lib/Drupal/Core/Entity/EntityTypeManager.php).

Proposed resolution

- Add a check in "Drupal\views\Plugin\views\field\EntityLabel"'s preRender method to ensure that entity type manager has plugin definition

Remaining tasks

-
-

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

๐Ÿ› Bug report
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Image moduleย  โ†’

Last updated about 3 hours ago

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia leopathu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @leopathu
  • Status changed to Postponed: needs info 2 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    Can you turn on verbose error reporting from admin/config/development/logging and provide the full stack trace? Thanks

  • Status changed to Active 2 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia leopathu

    Here is the Logs info

    The website encountered an unexpected error. Try again later.
    
    Drupal\Component\Plugin\Exception\PluginNotFoundException: The "default_image" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 139 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).
    Drupal\Core\Entity\EntityTypeManager->getHandler('default_image', 'storage') (Line: 192)
    Drupal\Core\Entity\EntityTypeManager->getStorage('default_image') (Line: 139)
    Drupal\views\Plugin\views\field\EntityLabel->preRender(Array) (Line: 1518)
    Drupal\views\ViewExecutable->render() (Line: 199)
    Drupal\views\Plugin\views\display\Page->execute() (Line: 1645)
    Drupal\views\ViewExecutable->executeDisplay('page_2', Array) (Line: 81)
    Drupal\views\Element\View::preRenderViewElement(Array)
    call_user_func_array(Array, Array) (Line: 111)
    Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 859)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 421)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
    Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 239)
    Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
    call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
    Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia Mingsong ๐Ÿ‡ฆ๐Ÿ‡บ

    I couldn't reproduce this error by the following steps on a Drupal 10.2.5 site:

    1. Go to the media overview page (/admin/content/media).
    2. Add a new media by clicking the link(button) 'Add media'.
    3. In the 'New media' page(/media/add), add an Image media.
    4. In the 'New image' page(/media/add/image), fill in all required fields, such as name, image file(uploaded).
    5. Save this new image media.
    6. Go to the file overview page(/admin/content/files)
    7. Click the file link uploaded by that image media above
    8. The image file open as expected. No error
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia leopathu

    @Mingsong It is happening only for default image uploaded on image fields.
    For example: Set a default image for any image field. and see the image file usage in the admin/content/files page. then you can get it.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    This looks like the views entity label plugin on this view is conflating the file usage type with an entity type

    The call to getStorage needs to check hasDefinition first

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia Mingsong ๐Ÿ‡ฆ๐Ÿ‡บ

    A new test to reproduce this error in 10.2.x branch.

    https://git.drupalcode.org/project/drupal/-/merge_requests/7660/diffs

  • Status changed to Needs work 2 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia Mingsong ๐Ÿ‡ฆ๐Ÿ‡บ
  • Pipeline finished with Failed
    2 months ago
    Total: 546s
    #153906
  • First commit to issue fork.
  • Pipeline finished with Failed
    2 months ago
    Total: 575s
    #156233
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia mohit_aghera Rajkot

    @Mingsong can you please update the PR with latest 11.x and change the destination for 11.x
    I've pushed the fix on the branch.
    There seems one test case failure, however this is failing on 11.x head as well (on my local).
    So not sure if this issue's change is the root cause of this one.

    Keeping this in needs work until we update the PR and pipeline is green.

  • Pipeline finished with Running
    2 months ago
    #156942
  • Pipeline finished with Failed
    2 months ago
    Total: 718s
    #156941
  • Pipeline finished with Failed
    2 months ago
    Total: 165s
    #156954
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia Mingsong ๐Ÿ‡ฆ๐Ÿ‡บ

    Thanks @Mohit for the fix.

    The origin branch is based on the 10.2.x branch and there are some conflicts if targeting 11.x branch.

    So I created a another branch based on the 11.x branch and a new MR targeting the 11.x branch.

    https://git.drupalcode.org/project/drupal/-/merge_requests/7752

    We need to fix this issue for all active branches(10.2.x, 10.3.x and 11.x)

    Cheers,

  • Pipeline finished with Success
    2 months ago
    Total: 994s
    #156969
  • Status changed to Needs review 2 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia Mingsong ๐Ÿ‡ฆ๐Ÿ‡บ
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia Mingsong ๐Ÿ‡ฆ๐Ÿ‡บ
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Kanchan Bhogade

    Hi
    I've tested MR !7752 on Drupal 10.2 and 11.x
    MR is applied cleanly...

    Test Result:
    No error for the default image uploaded on the image field on the file usage page and the "File Uses Page" is displayed.

    Adding Screenshots for references
    RTBC+1

    Keeping in "Needs review" for Code verification

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    smustgrave โ†’ changed the visibility of the branch 3442346-default-image-usage to hidden.

  • Pipeline finished with Success
    2 months ago
    Total: 1107s
    #158529
  • Status changed to Needs work 2 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave
    1) Drupal\Tests\file\Functional\FileImageTest::testDefaultImageFile
    Behat\Mink\Exception\ExpectationException: Current response status code is 500, but 200 expected.
    /builds/issue/drupal-3442346/vendor/behat/mink/src/WebAssert.php:888
    /builds/issue/drupal-3442346/vendor/behat/mink/src/WebAssert.php:145
    /builds/issue/drupal-3442346/core/modules/file/tests/src/Functional/FileImageTest.php:105
    /builds/issue/drupal-3442346/vendor/phpunit/phpunit/src/Framework/TestResult.php:729
    ERRORS!
    Tests: 1, Assertions: 9, Errors: 1.

    Shows test coverage.

    Left a comment on the MR though.

  • Pipeline finished with Success
    about 2 months ago
    Total: 1079s
    #159371
  • Status changed to Needs review about 2 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia Mingsong ๐Ÿ‡ฆ๐Ÿ‡บ
  • Status changed to RTBC about 2 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Much better to me, thanks for taking care of that.

  • Status changed to Needs work about 2 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    Nice one folks, couple of comments on the MR

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia pradhumanjainOSL

    pradhumanjain2311 โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia pradhumanjainOSL

    @larowlan i didn't understand how to remove getValue call but i tried to reduce a loop please review.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 1172s
    #160229
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    Left a comment clarifying my point @pradhumanjain2311 - thanks

  • Pipeline finished with Success
    about 2 months ago
    Total: 1043s
    #160260
  • Pipeline finished with Failed
    about 2 months ago
    Total: 1079s
    #160352
  • Pipeline finished with Success
    about 2 months ago
    Total: 1175s
    #160359
Production build 0.69.0 2024