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

I can't login admin panel #79

Open
JKair opened this issue Aug 28, 2021 · 10 comments
Open

I can't login admin panel #79

JKair opened this issue Aug 28, 2021 · 10 comments
Labels
bug Something isn't working

Comments

@JKair
Copy link

JKair commented Aug 28, 2021

Do you want to request a feature or report a bug?
bug

Bug: What is the current behavior?
When I enable this module,the admin panel will sign out soon after sign in.But the website front is normal.
Bug: What is the expected behavior?
sign in normal.
Bug: What is the proposed solution?

What is the version of Magento and of Sentry extension you are using? Always use the latest version of the extension one before opening a bug issue.
Magento version:2.4.2
sentry version:2.6

@JKair
Copy link
Author

JKair commented Aug 28, 2021

no error report in excetion.log

@indykoning
Copy link
Member

Hi, that is quite odd behavior we haven't experienced before.
Do you have the right configuration set in your env.php?
Is there maybe anything you see that might cause it in the system.log?
Or maybe something in your network tab?

I'm guessing there must be some error happening causing this logout.

I've checked on a production server running 2.4.2-p1 and it has no problems keeping me logged in in the backend.
I do suggest upgrading to 2.4.2-p2+ because of the security updates but i don't expect it to cause or fix this behavior.

@dzschille
Copy link

dzschille commented Sep 7, 2021

I have the same problem: i can log in but after the first click in the backend menu i get logged out. But the frontend works fine. In the Magento debug.log i see:

[2021-09-07 11:44:29] .DEBUG: Request validation failed for action "Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor" {"exception":"[object] (Magento\\Framework\\App\\Request\\InvalidRequestException(code: 0): Invalid request received at /var/www/online-shop2/public/vendor/magento/module-backend/App/Request/BackendValidator.php:176)"} []
[2021-09-07 11:44:29] .DEBUG: Source class "\Phalcon\Http\Message\Stream" for "Phalcon\Http\Message\StreamFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Stream\" for \"Phalcon\\Http\\Message\\StreamFactory\" generation does not exist. at /var/www/online-shop2/public/vendor/magento/framework/Code/Generator.php:222)"} []
[2021-09-07 11:44:29] .DEBUG: Source class "\Phalcon\Http\Message\Uri" for "Phalcon\Http\Message\UriFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Uri\" for \"Phalcon\\Http\\Message\\UriFactory\" generation does not exist. at /var/www/online-shop2/public/vendor/magento/framework/Code/Generator.php:222)"} []
[2021-09-07 11:44:29] .DEBUG: Source class "\Phalcon\Http\Message\Response" for "Phalcon\Http\Message\ResponseFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Response\" for \"Phalcon\\Http\\Message\\ResponseFactory\" generation does not exist. at /var/www/online-shop2/public/vendor/magento/framework/Code/Generator.php:222)"} []
[2021-09-07 11:44:29] .DEBUG: Source class "\Phalcon\Http\Message\Request" for "Phalcon\Http\Message\RequestFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Request\" for \"Phalcon\\Http\\Message\\RequestFactory\" generation does not exist. at /var/www/online-shop2/public/vendor/magento/framework/Code/Generator.php:222)"} []

Phalcon is just found in vendor/php-http/discovery:

$ grep -r Phalcon 
vendor/php-http/discovery/src/Strategy/CommonPsr17ClassesStrategy.php:            'Phalcon\Http\Message\RequestFactory',

As soon as i remove the "sentry" configuration from app/etc/env.php Phalcon doesn't appear in the debug log anymore.

I use
Magento 2.3.5-p2
justbetter/magento2-sentry: 2.6.0
Dependencies:
sentry/sdk: 3.1.0
sentry/sentry: 3.3.2
symfony/http-client: v5.3.7
monolog/monolog: 1.26.1
php-http/discovery: 1.14.0

@JKair
Copy link
Author

JKair commented Sep 9, 2021

@dzschille oh,guys,thanks for your info,I've been so busy lately that haven't time to give more info to @indykoning.

@simonmaass
Copy link

simonmaass commented Jun 13, 2022

I am experiencing the same problem in the logs - magento 2.4.4 and php8.1:

[2022-06-13T16:31:04.813915+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Response" for "Phalcon\Http\Message\ResponseFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Response\" for \"Phalcon\\Http\\Message\\ResponseFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
[2022-06-13T16:31:04.839274+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Response" for "Phalcon\Http\Message\ResponseFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Response\" for \"Phalcon\\Http\\Message\\ResponseFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
[2022-06-13T16:31:04.864525+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Stream" for "Phalcon\Http\Message\StreamFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Stream\" for \"Phalcon\\Http\\Message\\StreamFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
[2022-06-13T16:31:04.884219+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Stream" for "Phalcon\Http\Message\StreamFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Stream\" for \"Phalcon\\Http\\Message\\StreamFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
[2022-06-13T16:31:04.892928+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Request" for "Phalcon\Http\Message\RequestFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Request\" for \"Phalcon\\Http\\Message\\RequestFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
[2022-06-13T16:31:04.918881+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Request" for "Phalcon\Http\Message\RequestFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Request\" for \"Phalcon\\Http\\Message\\RequestFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
[2022-06-13T16:31:04.952301+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Uri" for "Phalcon\Http\Message\UriFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Uri\" for \"Phalcon\\Http\\Message\\UriFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
[2022-06-13T16:31:04.971579+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Uri" for "Phalcon\Http\Message\UriFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Uri\" for \"Phalcon\\Http\\Message\\UriFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
[2022-06-13T16:31:05.018918+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Response" for "Phalcon\Http\Message\ResponseFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Response\" for \"Phalcon\\Http\\Message\\ResponseFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
[2022-06-13T16:31:05.034931+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Response" for "Phalcon\Http\Message\ResponseFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Response\" for \"Phalcon\\Http\\Message\\ResponseFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
[2022-06-13T16:31:05.075022+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Request" for "Phalcon\Http\Message\RequestFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Request\" for \"Phalcon\\Http\\Message\\RequestFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []
[2022-06-13T16:31:05.089302+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Request" for "Phalcon\Http\Message\RequestFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Request\" for \"Phalcon\\Http\\Message\\RequestFactory\" generation does not exist. at vendor/magento/framework/Code/Generator.php:223)"} []

when i remove the sentry config from the .env then the logs disappear...

@dzschille
Copy link

We have also updated to Magento 2.4.4 and have still the same error:

[2022-08-03T11:47:54.914531+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Stream" for "Phalcon\Http\Message\StreamFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Stream\" for \"Phalcon\\Http\\Message\\StreamFactory\" generation does not exist. at /var/www/public/vendor/magento/framework/Code/Generator.php:223)"} []
[2022-08-03T11:47:54.915220+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Stream" for "Phalcon\Http\Message\StreamFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Stream\" for \"Phalcon\\Http\\Message\\StreamFactory\" generation does not exist. at /var/www/public/vendor/magento/framework/Code/Generator.php:223)"} []
[2022-08-03T11:47:54.915575+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Stream" for "Phalcon\Http\Message\StreamFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Stream\" for \"Phalcon\\Http\\Message\\StreamFactory\" generation does not exist. at /var/www/public/vendor/magento/framework/Code/Generator.php:223)"} []
[2022-08-03T11:47:54.916622+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Uri" for "Phalcon\Http\Message\UriFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Uri\" for \"Phalcon\\Http\\Message\\UriFactory\" generation does not exist. at /var/www/public/vendor/magento/framework/Code/Generator.php:223)"} []
[2022-08-03T11:47:54.917997+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Uri" for "Phalcon\Http\Message\UriFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Uri\" for \"Phalcon\\Http\\Message\\UriFactory\" generation does not exist. at /var/www/public/vendor/magento/framework/Code/Generator.php:223)"} []
[2022-08-03T11:47:54.918164+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Uri" for "Phalcon\Http\Message\UriFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Uri\" for \"Phalcon\\Http\\Message\\UriFactory\" generation does not exist. at /var/www/public/vendor/magento/framework/Code/Generator.php:223)"} []
[2022-08-03T11:47:54.918602+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Response" for "Phalcon\Http\Message\ResponseFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Response\" for \"Phalcon\\Http\\Message\\ResponseFactory\" generation does not exist. at /var/www/public/vendor/magento/framework/Code/Generator.php:223)"} []
[2022-08-03T11:47:54.920163+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Response" for "Phalcon\Http\Message\ResponseFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Response\" for \"Phalcon\\Http\\Message\\ResponseFactory\" generation does not exist. at /var/www/public/vendor/magento/framework/Code/Generator.php:223)"} []
[2022-08-03T11:47:54.920459+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Request" for "Phalcon\Http\Message\RequestFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Request\" for \"Phalcon\\Http\\Message\\RequestFactory\" generation does not exist. at /var/www/public/vendor/magento/framework/Code/Generator.php:223)"} []
[2022-08-03T11:47:54.920429+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Response" for "Phalcon\Http\Message\ResponseFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Response\" for \"Phalcon\\Http\\Message\\ResponseFactory\" generation does not exist. at /var/www/public/vendor/magento/framework/Code/Generator.php:223)"} []
[2022-08-03T11:47:54.922063+00:00] .DEBUG: Source class "\Phalcon\Http\Message\Request" for "Phalcon\Http\Message\RequestFactory" generation does not exist. {"exception":"[object] (RuntimeException(code: 0): Source class \"\\Phalcon\\Http\\Message\\Request\" for \"Phalcon\\Http\\Message\\RequestFactory\" generation does not exist. at /var/www/public/vendor/magento/framework/Code/Generator.php:223)"} []

When i remove the sentry config from app/etc/env.php then the logs disappears.

@simonmaass
Copy link

For now i just created this composer patch...

--- a/src/Strategy/CommonPsr17ClassesStrategy.php
+++ b/src/Strategy/CommonPsr17ClassesStrategy.php
@@ -21,7 +21,6 @@
      */
     private static $classes = [
         RequestFactoryInterface::class => [
-            'Phalcon\Http\Message\RequestFactory',
             'Nyholm\Psr7\Factory\Psr17Factory',
             'Zend\Diactoros\RequestFactory',
             'GuzzleHttp\Psr7\HttpFactory',
@@ -32,7 +31,6 @@
             'Slim\Psr7\Factory\RequestFactory',
         ],
         ResponseFactoryInterface::class => [
-            'Phalcon\Http\Message\ResponseFactory',
             'Nyholm\Psr7\Factory\Psr17Factory',
             'Zend\Diactoros\ResponseFactory',
             'GuzzleHttp\Psr7\HttpFactory',
@@ -43,7 +41,6 @@
             'Slim\Psr7\Factory\ResponseFactory',
         ],
         ServerRequestFactoryInterface::class => [
-            'Phalcon\Http\Message\ServerRequestFactory',
             'Nyholm\Psr7\Factory\Psr17Factory',
             'Zend\Diactoros\ServerRequestFactory',
             'GuzzleHttp\Psr7\HttpFactory',
@@ -54,7 +51,6 @@
             'Slim\Psr7\Factory\ServerRequestFactory',
         ],
         StreamFactoryInterface::class => [
-            'Phalcon\Http\Message\StreamFactory',
             'Nyholm\Psr7\Factory\Psr17Factory',
             'Zend\Diactoros\StreamFactory',
             'GuzzleHttp\Psr7\HttpFactory',
@@ -65,7 +61,6 @@
             'Slim\Psr7\Factory\StreamFactory',
         ],
         UploadedFileFactoryInterface::class => [
-            'Phalcon\Http\Message\UploadedFileFactory',
             'Nyholm\Psr7\Factory\Psr17Factory',
             'Zend\Diactoros\UploadedFileFactory',
             'GuzzleHttp\Psr7\HttpFactory',
@@ -76,7 +71,6 @@
             'Slim\Psr7\Factory\UploadedFileFactory',
         ],
         UriFactoryInterface::class => [
-            'Phalcon\Http\Message\UriFactory',
             'Nyholm\Psr7\Factory\Psr17Factory',
             'Zend\Diactoros\UriFactory',
             'GuzzleHttp\Psr7\HttpFactory',

@indykoning
Copy link
Member

I think this may have to do with Sentry's dependency on php-http/discovery which may cause issues.

I know the Magento integration does not need any of these classes itself.
What kind of environment is this being run on?
On a server with production settings no debug.log should get created and on a test/local environment no class generation should occur...

I'm afraid i can't reproduce these debug logs on either environment

@indykoning
Copy link
Member

We've done some more digging and sadly we're completely unable to fix this from our side.

The log spam should not cause any problems though.

Because of Magento's automatic Factory generation while developer mode is active it will try to generate factories for classes that don't exist, for packages that don't exist if you try to call class_exists
php-http/discovery is already catching this and checking the next file.
https://github.com/php-http/discovery/blob/69e1a26f51fb4c5c7f2e5f0903f83c6229df269b/src/ClassDiscovery.php#L239-L243

Magento tries to generate the class when you call it using the folowing function:
https://github.com/magento/magento2/blob/adc4105fcfbeee29d534482d8c6d9c5c1a193a0c/lib/internal/Magento/Framework/Code/Generator.php#L214

Which fails and throws an exception.
To be caught by the autoloader of Magento and gets logged to the debug log

https://github.com/magento/magento2/blob/adc4105fcfbeee29d534482d8c6d9c5c1a193a0c/lib/internal/Magento/Framework/Code/Generator/Autoloader.php#L55

It's all because of quirks and "features" of Magento's code and factory generation not playing too nice with class_exists.
However this should not be a problem in production environments where setup:di:compile has been run.

@indykoning
Copy link
Member

To the point of this specific issue, are there still any problems logging into the admin pannel?

@indykoning indykoning added bug Something isn't working wontfix This will not be worked on and removed wontfix This will not be worked on labels Mar 27, 2024
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

No branches or pull requests

4 participants