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

Argument 1 passed to Symfony\Component\Routing\RequestContext::fromRequest() must be an instance of Symfony\Component\HttpFoundation\Request, null given #28

Open
francesco-laricchia opened this issue Jan 24, 2019 · 5 comments

Comments

@francesco-laricchia
Copy link

Got this error, can't figure out why. Running v0.10.0 on Symfony 3.4.14.

10:40:46 ERROR [console] Error thrown while running command "**debug:event-dispatcher**". Message: "Argument 1 passed to Symfony\Component\Routing\RequestContext::fromRequest() must be an instance of Symfony\Component\HttpFoundation\Request, null given, called in /Volumes/Dati/WORK/icgest/vendor/adactive-sas/saml2-bridge-bundle/src/Entity/HostedEntities.php on line 141" ["exception" => TypeError { …},"command" => "debug:event-dispatcher","message" => "**Argument 1 passed to Symfony\Component\Routing\RequestContext::fromRequest() must be an instance of Symfony\Component\HttpFoundation\Request, null given, called in /Volumes/Dati/WORK/icgest/vendor/adactive-sas/saml2-bridge-bundle/src/Entity/HostedEntities.php on line 141**"] []

@marnixbent
Copy link

I think you will need to dig a bit deeper. There is no request object present, so is the entire process initiated by an internal redirect / call / command somehow?

@moroine
Copy link
Contributor

moroine commented Jan 26, 2019

I don't have enough context to dig into.

Your error seems to come from https://github.com/AdactiveSAS/saml2-bridge-bundle/blob/master/src/Entity/HostedEntities.php#L141 where the bundle retrieves the master request from request_stack service.

Could you provide a complete stack trace?

@francesco-laricchia
Copy link
Author

I'm new to SAML so I'm probably missing something. Anyway, it seems to works flawlessly during normal operations, while only the command

php bin/console debug:event-dispatcher

triggers this error. Here's the output in verbose mode, it's all I got:

$ php bin/console debug:event-dispatcher -vvv
08:58:46 DEBUG [event] Notified event "console.command" to listener "Symfony\Component\HttpKernel\EventListener\DumpListener::configure".
[
"event" => "console.command",
"listener" => "Symfony\Component\HttpKernel\EventListener\DumpListener::configure"
]
[]
08:58:46 DEBUG [event] Notified event "console.command" to listener "Symfony\Bridge\Monolog\Handler\ConsoleHandler::onCommand".
[
"event" => "console.command",
"listener" => "Symfony\Bridge\Monolog\Handler\ConsoleHandler::onCommand"
]
[]

Registered Listeners Grouped by Event

08:58:46 ERROR [console] Error thrown while running command "debug:event-dispatcher -vvv". Message: "Argument 1 passed to Symfony\Component\Routing\RequestContext::fromRequest() must be an instance of Symfony\Component\HttpFoundation\Request, null given, called in /Volumes/Dati/WORK/icgest/vendor/adactive-sas/saml2-bridge-bundle/src/Entity/HostedEntities.php on line 141"
[
"exception" => TypeError {
#message: "Argument 1 passed to Symfony\Component\Routing\RequestContext::fromRequest() must be an instance of Symfony\Component\HttpFoundation\Request, null given, called in /Volumes/Dati/WORK/icgest/vendor/adactive-sas/saml2-bridge-bundle/src/Entity/HostedEntities.php on line 141"
#code: 0
#file: "./vendor/symfony/symfony/src/Symfony/Component/Routing/RequestContext.php"
#line: 63
trace: {
./vendor/symfony/symfony/src/Symfony/Component/Routing/RequestContext.php:63 { …}
./vendor/adactive-sas/saml2-bridge-bundle/src/Entity/HostedEntities.php:141 { …}
./vendor/adactive-sas/saml2-bridge-bundle/src/Entity/HostedEntities.php:73 { …}
./vendor/adactive-sas/saml2-bridge-bundle/src/Entity/HostedEntities.php:122 { …}
./vendor/adactive-sas/saml2-bridge-bundle/src/Entity/HostedEntities.php:96 { …}
./var/cache/dev/ContainerJamqlft/appDevDebugProjectContainer.php:1921 {
› {
› return $this->services['adactive_sas_saml2_bridge.hosted.identity_provider'] = ${($_ = isset($this->services['adactive_sas_saml2_bridge.configuration.hosted_entities']) ? $this->services['adactive_sas_saml2_bridge.configuration.hosted_entities'] : $this->getAdactiveSasSaml2Bridge_Configuration_HostedEntitiesService()) && false ?: '_'}->getIdentityProvider();
› }
}
./var/cache/dev/ContainerJamqlft/appDevDebugProjectContainer.php:1530 { …}
./var/cache/dev/ContainerJamqlft/appDevDebugProjectContainer.php:2398 { …}
./vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:229 { …}
./vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:69 { …}
./vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php:128 { …}
./vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:92 { …}
./vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php:403 { …}
./vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php:72 { …}
./vendor/symfony/symfony/src/Symfony/Component/Console/Helper/DescriptorHelper.php:69 { …}
./vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php:106 { …}
./vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:251 { …}
./vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:964 { …}
./vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:86 { …}
./vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:248 { …}
./vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:74 { …}
./vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:148 { …}
./bin/console:27 { …}
}
},
"command" => "debug:event-dispatcher -vvv",
"message" => "Argument 1 passed to Symfony\Component\Routing\RequestContext::fromRequest() must be an instance of Symfony\Component\HttpFoundation\Request, null given, called in /Volumes/Dati/WORK/icgest/vendor/adactive-sas/saml2-bridge-bundle/src/Entity/HostedEntities.php on line 141"
]
[]
08:58:46 DEBUG [event] Notified event "console.error" to listener "Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onException".
[
"event" => "console.error",
"listener" => "Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onException"
]
[]
08:58:46 DEBUG [event] Notified event "console.error" to listener "Symfony\Component\Console\EventListener\ErrorListener::onConsoleError".
[
"event" => "console.error",
"listener" => "Symfony\Component\Console\EventListener\ErrorListener::onConsoleError"
]
[]
08:58:46 DEBUG [console] Command "debug:event-dispatcher -vvv" exited with code "1"
[
"command" => "debug:event-dispatcher -vvv",
"code" => 1
]
[]

Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to Symfony\Component\Routing\RequestContext::fromRequest() must be an instance of Symfony\Component\HttpFoundation\Request, null given, called in /Volumes/Dati/WORK/icgest/vendor/adactive-sas/saml2-bridge-bundle/src/Entity/HostedEntities.php on line 141 in /Volumes/Dati/WORK/icgest/vendor/symfony/symfony/src/Symfony/Component/Routing/RequestContext.php on line 63

Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to Symfony\Component\Routing\RequestContext::fromRequest() must be an instance of Symfony\Component\HttpFoundation\Request, null given, called in /Volumes/Dati/WORK/icgest/vendor/adactive-sas/saml2-bridge-bundle/src/Entity/HostedEntities.php on line 141 in /Volumes/Dati/WORK/icgest/vendor/symfony/symfony/src/Symfony/Component/Routing/RequestContext.php on line 63

Call Stack:
0.8684 6727976 1. Symfony\Component\Debug\ErrorHandler->handleException() /Volumes/Dati/WORK/icgest/vendor/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php:0

@moroine
Copy link
Contributor

moroine commented Jan 28, 2019

OK so the issue is only when running console command. Which makes sense as it rely on request_stack.

You can try to do a PR otherwise I'll have a look this weekend.

@alexislefebvre
Copy link

Google brought me here, here is the solution:

Had this problem updating from Symfony 3 to Symfony 4, found the fix to be changing out configuration files.

Before:

router.request_context.base_url: ~

After:

router.request_context.base_url: ""

Source: https://stackoverflow.com/questions/59009344/fatalerror-with-requestcontext-constructor/61460543#61460543

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants