Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apigee Edge Teams module throws an error upon invitation #715

Closed
boobaa opened this issue Jun 10, 2022 · 5 comments · Fixed by #716
Closed

Apigee Edge Teams module throws an error upon invitation #715

boobaa opened this issue Jun 10, 2022 · 5 comments · Fixed by #716
Labels
bug Something isn't working

Comments

@boobaa
Copy link
Contributor

boobaa commented Jun 10, 2022

Description

When I enter an email address of a member I want to invite (either an already existing user on the portal or a user that is not a registered user yet), and I click the "Invite members" button, I get an error, tho the invitation email is sent out.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Go to any team's member list (ie. visit /teams/{team}/members page).
  2. Click "Invite members".
  3. Enter an email and click "Invite members".

Actual Behavior

This error is displayed:

The website encountered an unexpected error. Please try again later.
TypeError: Return value of Drupal\apigee_edge_teams\TeamInvitationNotifierEmail::sendNotificationsFor() must be of the type bool, null returned in Drupal\apigee_edge_teams\TeamInvitationNotifierEmail->sendNotificationsFor() (line 80 of modules/contrib/apigee_edge/modules/apigee_edge_teams/src/TeamInvitationNotifierEmail.php).
Drupal\apigee_edge_teams\TeamInvitationNotifierEmail->sendNotificationsFor() (Line: 115)
Drupal\apigee_edge_teams\EventSubscriber\TeamInvitationSubscriber->onCreated()
call_user_func() (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 120)
Drupal\apigee_edge_teams\Entity\Storage\TeamInvitationStorage->invokeHook() (Line: 602)
Drupal\Core\Entity\EntityStorageBase->doPostSave() (Line: 785)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave() (Line: 527)
Drupal\Core\Entity\EntityStorageBase->save() (Line: 802)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 203)
Drupal\apigee_edge_teams\Form\AddTeamMembersForm->submitForm()
call_user_func_array() (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 592)
Drupal\Core\Form\FormBuilder->processForm() (Line: 320)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 708)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Expected Behavior

  • The invitation email is sent out.
  • No error is displayed, but I end up on the list of the team members.

Screenshots

(not applicable, see the error above)

Notes

(none)

Version Info

drupal/core                                               9.3.15       Drupal is an open source content management platform powering millions of websites and applications.
drupal/apigee_edge                                        2.0.4        Apigee Edge for Drupal.
apigee/apigee-client-php                                  2.0.16       Client library for connecting to the Apigee Edge API.
@boobaa boobaa added the bug Something isn't working label Jun 10, 2022
@shishir-intelli
Copy link
Collaborator

Hi @boobaa
I've tried to replicate it locally, but could not see any errors.
It seems that TeamInvitationNotifierEmail::sendNotificationsFor() method is returning null while triggering the email.

To investigate further on the same can you please share the Drupal error logs (/admin/reports/dblog) to check if there are any other errors.

@boobaa
Copy link
Contributor Author

boobaa commented Jun 13, 2022

Hi @shishir-intelli, I also checked this again.

  1. Turns out the "Pending Invitations" does contain the email I entered besides the error, so I updated my report accordingly.
  2. The only other watchdog entry is the one below, which pretty much has the same info:
Notice: Trying to access array offset on value of type null in Drupal\apigee_edge_teams\TeamInvitationNotifierEmail->sendNotificationsFor() (line 80 of /mnt/files/local_mount/build/web/modules/contrib/apigee_edge/modules/apigee_edge_teams/src/TeamInvitationNotifierEmail.php)
#0 /mnt/files/local_mount/build/web/core/includes/bootstrap.inc(346): _drupal_error_handler_real()
#1 /mnt/files/local_mount/build/web/modules/contrib/apigee_edge/modules/apigee_edge_teams/src/TeamInvitationNotifierEmail.php(80): _drupal_error_handler()
#2 /mnt/files/local_mount/build/web/modules/contrib/apigee_edge/modules/apigee_edge_teams/src/EventSubscriber/TeamInvitationSubscriber.php(115): Drupal\apigee_edge_teams\TeamInvitationNotifierEmail->sendNotificationsFor()
#3 [internal function]: Drupal\apigee_edge_teams\EventSubscriber\TeamInvitationSubscriber->onCreated()
#4 /mnt/files/local_mount/build/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func()
#5 /mnt/files/local_mount/build/web/modules/contrib/apigee_edge/modules/apigee_edge_teams/src/Entity/Storage/TeamInvitationStorage.php(120): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#6 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(602): Drupal\apigee_edge_teams\Entity\Storage\TeamInvitationStorage->invokeHook()
#7 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(785): Drupal\Core\Entity\EntityStorageBase->doPostSave()
#8 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(527): Drupal\Core\Entity\ContentEntityStorageBase->doPostSave()
#9 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(802): Drupal\Core\Entity\EntityStorageBase->save()
#10 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/Entity/EntityBase.php(339): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()
#11 /mnt/files/local_mount/build/web/modules/contrib/apigee_edge/modules/apigee_edge_teams/src/Form/AddTeamMembersForm.php(203): Drupal\Core\Entity\EntityBase->save()
#12 [internal function]: Drupal\apigee_edge_teams\Form\AddTeamMembersForm->submitForm()
#13 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/Form/FormSubmitter.php(114): call_user_func_array()
#14 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/Form/FormSubmitter.php(52): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers()
#15 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/Form/FormBuilder.php(592): Drupal\Core\Form\FormSubmitter->doSubmitForm()
#16 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/Form/FormBuilder.php(320): Drupal\Core\Form\FormBuilder->processForm()
#17 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#18 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#19 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#20 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/Render/Renderer.php(564): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#21 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#22 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#23 /mnt/files/local_mount/build/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#24 /mnt/files/local_mount/build/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#25 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#26 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#27 /mnt/files/local_mount/build/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#28 /mnt/files/local_mount/build/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#29 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#30 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#31 /mnt/files/local_mount/build/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#32 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle()
#33 /mnt/files/local_mount/build/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#34 {main}
.

@shishir-intelli
Copy link
Collaborator

Hi @boobaa

I have attached a patch file which prevents the error when Null response is received, Can you please apply this patch and let us know if this works also check if the user/receiver has received an invitation email.
Patch patch-issue715.txt

@boobaa
Copy link
Contributor Author

boobaa commented Jun 14, 2022

Hi @shishir-intelli,

Thank you for creating the patch. I can confirm it solves the problem: the email is sent, the sender sees no errors, and there are no errors/notices in the logs either.

@shishir-intelli
Copy link
Collaborator

shishir-intelli commented Jun 14, 2022

Hi @boobaa
Thanks for testing this patch!
This error is thrown when the sent mail response result is NULL and this happens when a hook_mail_alter() is implemented somewhere to cancel the sending.

Reference : https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Mail%21MailManager.php/class/MailManager/8.2.x#:~:text=send%27%5D))%20%7B%0A%20%20%20%20%20%20%20%20%24-,message,-%5B%27result%27

However, IMO it's good to prevent this error, I will create a PR for the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants