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

[BUG]: 5.3.1 to 5.4.0: Phalcon\Mvc\Router\Exception: A dependency injection container is required to access the 'request' service #16460

Open
fichtner opened this issue Oct 28, 2023 · 9 comments
Assignees
Labels
bug A bug report status: unverified Unverified

Comments

@fichtner
Copy link

fichtner commented Oct 28, 2023

Describe the bug
Exception after updating from 5.3.1 to 5.4.0:

[28-Oct-2023 10:34:51 Europe/Berlin] Phalcon\Mvc\Router\Exception: A dependency injection container is required to access the 'request' service in phalcon/Mvc/Router.zep:724
Stack trace:
#0 /usr/local/opnsense/mvc/app/config/services_api.php(92): Phalcon\Mvc\Router->handle('/api/routes/gat...')
#1 [internal function]: Closure->{closure}()
#2 [internal function]: Phalcon\Di\Service->resolve(NULL, Object(Phalcon\Di\FactoryDefault))
#3 [internal function]: Phalcon\Di\Di->get('router', NULL)
#4 [internal function]: Phalcon\Di\Di->getShared('router')
#5 /usr/local/opnsense/www/api.php(24): Phalcon\Mvc\Application->handle('/api/routes/gat...')
#6 {main}

To Reproduce

Our code in question has been working through multiple Phalcon major versions here. Code reference:

https://github.com/opnsense/core/blob/d560e84934d5f00a3dfa10245fd3853a3f7e6ab3/src/opnsense/mvc/app/config/services_api.php#L90L94

Expected behavior

Act like 5.3.x ideally. Could be something we handled wrong here forever though.

Screenshots

N/A

Details

5.4.0

  • Phalcon version: 5.4.0
  • PHP Version: 8.2.11
  • Operating System: FreeBSD 13.2
  • Installation type: package manager (test build)
  • Server: Lighttpd

Additional context

N/A

@fichtner fichtner added bug A bug report status: unverified Unverified labels Oct 28, 2023
@niden niden self-assigned this Oct 28, 2023
@niden
Copy link
Sponsor Member

niden commented Oct 28, 2023

@fichtner I did a diff between 5.3.1 and 5.4.0 and did not see any changes in the router or anything else that might be indicative of why you see this error.

In the Router code the check is this:

        let container = <DiInterface> this->container;
        if container === null {
            throw new Exception(
                "A dependency injection container is required to access the 'request' service"
            );
        }

so Phalcon sees that the container is null.

If you want ping me in discord to try and diagnose this further, since I will need help to set opnsense up on my local to debug.

@fichtner
Copy link
Author

Thanks for taking a closer look. Let me see if I can reproduce this with a clean build on Monday and let you have a simple script that triggers this too before proceeding.

Cheers,
Franco

@fichtner
Copy link
Author

I had some spare time: clean compile and issue still exists. Also glanced over the diff on your end but came up empty as well. FactoryDefault works the same before and after, but the router attach is being weird. I'll find you on Monday, maybe you have ideas how to approach this. I could also do a bisect on the changes perhaps.

Cheers,
Franco

@fichtner
Copy link
Author

Still the case on 5.6.1. Can we pick this back up? I reckon it might be more of an application issue, but still sort of a regression that I can't wrap my head around.

Cheers,
Franco

fichtner added a commit to opnsense/core that referenced this issue Feb 12, 2024
@fichtner
Copy link
Author

I followed similar reports and ended up "fixing" it with opnsense/core@5f855524e -- for me it's ok to close but I'd like someone to look if that was intended... :)

fichtner added a commit to opnsense/core that referenced this issue Feb 13, 2024
See also: phalcon/cphalcon#16460

(cherry picked from commit 5f85552)
@zoechi
Copy link

zoechi commented Mar 1, 2024

I run into this as well after an OPNSense update 2 days ago.

@fichtner
Copy link
Author

fichtner commented Mar 1, 2024

@zoechi wrong repo and no actual information attached to be of any help

@zoechi
Copy link

zoechi commented Mar 1, 2024

@fichtner it was the only search result. Sorry for not providing more information.
I was able to update OPNSense using ssh and now it's working again.

@fichtner
Copy link
Author

fichtner commented Mar 1, 2024

Was probably in an intermittent update state with newer Phalcon package and older core package. All patched to 24.1.2 should get rid of the error for good indeed. 😊

fichtner added a commit to opnsense/core that referenced this issue Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: unverified Unverified
Projects
None yet
Development

No branches or pull requests

3 participants