Drupal\consumers\MissingConsumer: Unable to find the default consumer. in Drupal\consumers\Negotiator->loadDefaultConsumer() (line 141 of /var/www/html/web/modules/contrib/consumers/src/Negotiator.php).

Created on 23 July 2024, 3 months ago
Updated 8 August 2024, 2 months ago

Problem/Motivation

After updating to the 1.18.0 release, the website isn't accessible any longer. Instead, it logs that exception:

Drupal\consumers\MissingConsumer: Unable to find the default consumer. in Drupal\consumers\Negotiator->loadDefaultConsumer() (line 141 of /var/www/html/web/modules/contrib/consumers/src/Negotiator.php).
🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇩🇪Germany jurgenhaas Gottmadingen

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

Merge Requests

Comments & Activities

  • Issue created by @jurgenhaas
  • 🇩🇪Germany jurgenhaas Gottmadingen

    The problem was that none of the consumer entities was defined as default before. No idea, if the default is something new?

    What resolved the issue is the following SQL statement in my case:

    update consumer_field_data set is_default=1 where id=2;
    
  • 🇸🇮Slovenia nkoporec Slovenia

    I'm also seeing this issue if there are no consumers (empty list of entities), this occurred after we updated from 1.17 to 1.18.... did not debug it further but my fix was to simply downgrade it for now back to 1.17.

  • Assigned to eojthebrave
  • 🇺🇸United States eojthebrave Minneapolis, MN

    It looks like this is caused by code that was added in 🐛 Cacheability issue when using _consumer_id query in JsonApi responses. Needs work . And that if there are no consumer entities, or none marked as default, then this method \Drupal\consumers\EventSubscriber\ConsumerVaryEventSubscriber::onRespond has an unhandled exception. And we need to catch that exception and just not set a Vary header if there are no consumers in the request.

    I'll work on getting a fix for this ASAP.

  • Pipeline finished with Skipped
    3 months ago
    #232318
    • eojthebrave committed edeec422 on 8.x-1.x
      Issue #3463248 by eojthebrave: Drupal\consumers\MissingConsumer: Unable...
  • Issue was unassigned.
  • Status changed to Fixed 3 months ago
  • 🇺🇸United States eojthebrave Minneapolis, MN

    I've just merged in an update that handles setting the Vary header in the scenario where there are either no consumer entities, or no consumer defined as the default and none present in the request header. I also added what are essentially smoke tests to make sure we don't re-introduce this same problem again in the future.

    I'll tag a new 8.x-1.19 release shortly.

    @jurgenhaas, and @nkoporec if you could test this new release out and let me know if it resolves the issues you're encountering that would be great.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Thanks @eojthebrave for addressing this so quickly. It's difficult to test as I've resolved the issue with the approach from #2.

    Just wondering, are you not granting issue credits for reporting and analysing issues?

  • 🇺🇸United States eojthebrave Minneapolis, MN

    Oops. Forgot about that. Added the credit, and thanks for the reminder.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024