opnsense / plugins

OPNsense plugin collection
https://opnsense.org/
BSD 2-Clause "Simplified" License
849 stars 644 forks source link

[os-nginx] Unable to save configuration #4342

Closed twocore closed 2 weeks ago

twocore commented 3 weeks ago

Important notices Before you add a new report, we ask you kindly to acknowledge the following:

Describe the bug

I upgraded my OPNsense from 24.7.7 to 24.7.8 last night. Since then I can no longer save the configuration for existing elements or create new ones (sorry for my english). In the Web GUI i got Unexpected error, check log for details.

To Reproduce

Try to change e.g. items in "HTTP Server" and click "Save".

Expected behavior

Configuration is saved without any errors.

Relevant log files

[08-Nov-2024 11:07:41 Europe/Berlin] Error: Call to undefined method OPNsense\Base\Constraints\NgxBusyBufferConstraint::isEmpty() in /usr/local/opnsense/mvc/app/models/OPNsense/Base/Constraints/NgxBusyBufferConstraint.php:46
Stack trace:
#0 /usr/local/opnsense/mvc/app/models/OPNsense/Base/Validation.php(83): OPNsense\Base\Constraints\NgxBusyBufferConstraint->validate(Object(OPNsense\Base\Validation), 'location.7aa3c5...')
#1 /usr/local/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php(517): OPNsense\Base\Validation->validate(Array)
#2 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(260): OPNsense\Base\BaseModel->performValidation(true)
#3 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(551): OPNsense\Base\ApiMutableModelControllerBase->validate(Object(OPNsense\Base\FieldTypes\ContainerField), 'upstream', true)
#4 /usr/local/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/SettingsController.php(129): OPNsense\Base\ApiMutableModelControllerBase->setBase('upstream', 'upstream', '8fb9f94c-6cd4-4...')
#5 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Dispatcher.php(165): OPNsense\Nginx\Api\SettingsController->setupstreamAction('8fb9f94c-6cd4-4...')
#6 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(156): OPNsense\Mvc\Dispatcher->dispatch(Object(OPNsense\Mvc\Request), Object(OPNsense\Mvc\Response), Object(OPNsense\Mvc\Session))
#7 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(139): OPNsense\Mvc\Router->performRequest(Object(OPNsense\Mvc\Dispatcher))
#8 /usr/local/opnsense/www/api.php(36): OPNsense\Mvc\Router->routeRequest('/api/nginx/sett...', Array)
#9 {main}
[08-Nov-2024 11:18:11 Europe/Berlin] Error: Call to undefined method OPNsense\Base\Constraints\NgxBusyBufferConstraint::isEmpty() in /usr/local/opnsense/mvc/app/models/OPNsense/Base/Constraints/NgxBusyBufferConstraint.php:46
Stack trace:
#0 /usr/local/opnsense/mvc/app/models/OPNsense/Base/Validation.php(83): OPNsense\Base\Constraints\NgxBusyBufferConstraint->validate(Object(OPNsense\Base\Validation), 'location.7aa3c5...')
#1 /usr/local/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php(517): OPNsense\Base\Validation->validate(Array)
#2 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(260): OPNsense\Base\BaseModel->performValidation(true)
#3 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(551): OPNsense\Base\ApiMutableModelControllerBase->validate(Object(OPNsense\Base\FieldTypes\ContainerField), 'httpserver', true)
#4 /usr/local/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/SettingsController.php(286): OPNsense\Base\ApiMutableModelControllerBase->setBase('httpserver', 'http_server', 'b3a371f3-ce3d-4...')
#5 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Dispatcher.php(165): OPNsense\Nginx\Api\SettingsController->sethttpserverAction('b3a371f3-ce3d-4...')
#6 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(156): OPNsense\Mvc\Dispatcher->dispatch(Object(OPNsense\Mvc\Request), Object(OPNsense\Mvc\Response), Object(OPNsense\Mvc\Session))
#7 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(139): OPNsense\Mvc\Router->performRequest(Object(OPNsense\Mvc\Dispatcher))
#8 /usr/local/opnsense/www/api.php(36): OPNsense\Mvc\Router->routeRequest('/api/nginx/sett...', Array)
#9 {main}

Additional context Add any other context about the problem here.

Environment

OPNsense 24.7.8-amd64 FreeBSD 14.1-RELEASE-p6 OpenSSL 3.0.15

Intel(R) Celeron(R) J4125 CPU

pacobattistini commented 3 weeks ago

Hi, I’m using Opnsense 24.7.8 in the same environment, and I’m unable to make any changes to the nginx configuration. The system only returns "Unexpected error, check log for details."

markusnasholm commented 2 weeks ago

Hi. I can confirm the same issue.

TheRouCo commented 2 weeks ago

Hi. I am having the same issue here. 24.7.8 and NGINX Plugin 1.34_2. In my case, when trying to create or edit a location. System returning:

"Unexpected error, check log for details."

Log Trace:

`Nov-2024 23:06:17 Etc/GMT-3] Error: Call to undefined method OPNsense\Base\Constraints\NgxBusyBufferConstraint::isEmpty() in /usr/local/opnsense/mvc/app/models/OPNsense/Base/Constraints/NgxBusyBufferConstraint.php:46 Stack trace:

0 /usr/local/opnsense/mvc/app/models/OPNsense/Base/Validation.php(83): OPNsense\Base\Constraints\NgxBusyBufferConstraint->validate(Object(OPNsense\Base\Validation), 'location.4fecaf...')

1 /usr/local/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php(517): OPNsense\Base\Validation->validate(Array)

2 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(260): OPNsense\Base\BaseModel->performValidation(false)

3 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(466): OPNsense\Base\ApiMutableModelControllerBase->validate(Object(OPNsense\Base\FieldTypes\ContainerField), 'location')

4 /usr/local/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/SettingsController.php(192): OPNsense\Base\ApiMutableModelControllerBase->addBase('location', 'location')

5 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Dispatcher.php(165): OPNsense\Nginx\Api\SettingsController->addlocationAction()

6 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(156): OPNsense\Mvc\Dispatcher->dispatch(Object(OPNsense\Mvc\Request), Object(OPNsense\Mvc\Response), Object(OPNsense\Mvc\Session))

7 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(139): OPNsense\Mvc\Router->performRequest(Object(OPNsense\Mvc\Dispatcher))

8 /usr/local/opnsense/www/api.php(36): OPNsense\Mvc\Router->routeRequest('/api/nginx/sett...', Array)

9 {main}

[08-Nov-2024 23:07:04 Etc/GMT-3] Error: Call to undefined method OPNsense\Base\Constraints\NgxBusyBufferConstraint::isEmpty() in /usr/local/opnsense/mvc/app/models/OPNsense/Base/Constraints/NgxBusyBufferConstraint.php:46 Stack trace:

0 /usr/local/opnsense/mvc/app/models/OPNsense/Base/Validation.php(83): OPNsense\Base\Constraints\NgxBusyBufferConstraint->validate(Object(OPNsense\Base\Validation), 'location.73b8d8...')

1 /usr/local/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php(517): OPNsense\Base\Validation->validate(Array)

2 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(260): OPNsense\Base\BaseModel->performValidation(false)

3 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(466): OPNsense\Base\ApiMutableModelControllerBase->validate(Object(OPNsense\Base\FieldTypes\ContainerField), 'location')

4 /usr/local/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/SettingsController.php(192): OPNsense\Base\ApiMutableModelControllerBase->addBase('location', 'location')

5 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Dispatcher.php(165): OPNsense\Nginx\Api\SettingsController->addlocationAction()

6 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(156): OPNsense\Mvc\Dispatcher->dispatch(Object(OPNsense\Mvc\Request), Object(OPNsense\Mvc\Response), Object(OPNsense\Mvc\Session))

7 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(139): OPNsense\Mvc\Router->performRequest(Object(OPNsense\Mvc\Dispatcher))

8 /usr/local/opnsense/www/api.php(36): OPNsense\Mvc\Router->routeRequest('/api/nginx/sett...', Array)

9 {main}

[08-Nov-2024 23:07:38 Etc/GMT-3] Error: Call to undefined method OPNsense\Base\Constraints\NgxBusyBufferConstraint::isEmpty() in /usr/local/opnsense/mvc/app/models/OPNsense/Base/Constraints/NgxBusyBufferConstraint.php:46 Stack trace:

0 /usr/local/opnsense/mvc/app/models/OPNsense/Base/Validation.php(83): OPNsense\Base\Constraints\NgxBusyBufferConstraint->validate(Object(OPNsense\Base\Validation), 'location.20538b...')

1 /usr/local/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php(517): OPNsense\Base\Validation->validate(Array)

2 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(260): OPNsense\Base\BaseModel->performValidation(false)

3 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(466): OPNsense\Base\ApiMutableModelControllerBase->validate(Object(OPNsense\Base\FieldTypes\ContainerField), 'location')

4 /usr/local/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/SettingsController.php(192): OPNsense\Base\ApiMutableModelControllerBase->addBase('location', 'location')

5 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Dispatcher.php(165): OPNsense\Nginx\Api\SettingsController->addlocationAction()

6 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(156): OPNsense\Mvc\Dispatcher->dispatch(Object(OPNsense\Mvc\Request), Object(OPNsense\Mvc\Response), Object(OPNsense\Mvc\Session))

7 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(139): OPNsense\Mvc\Router->performRequest(Object(OPNsense\Mvc\Dispatcher))

8 /usr/local/opnsense/www/api.php(36): OPNsense\Mvc\Router->routeRequest('/api/nginx/sett...', Array)

9 {main}

[08-Nov-2024 23:07:43 Etc/GMT-3] Error: Call to undefined method OPNsense\Base\Constraints\NgxBusyBufferConstraint::isEmpty() in /usr/local/opnsense/mvc/app/models/OPNsense/Base/Constraints/NgxBusyBufferConstraint.php:46 Stack trace:

0 /usr/local/opnsense/mvc/app/models/OPNsense/Base/Validation.php(83): OPNsense\Base\Constraints\NgxBusyBufferConstraint->validate(Object(OPNsense\Base\Validation), 'location.9ecad1...')

1 /usr/local/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php(517): OPNsense\Base\Validation->validate(Array)

2 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(260): OPNsense\Base\BaseModel->performValidation(false)

3 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(466): OPNsense\Base\ApiMutableModelControllerBase->validate(Object(OPNsense\Base\FieldTypes\ContainerField), 'location')

4 /usr/local/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/SettingsController.php(192): OPNsense\Base\ApiMutableModelControllerBase->addBase('location', 'location')

5 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Dispatcher.php(165): OPNsense\Nginx\Api\SettingsController->addlocationAction()

6 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(156): OPNsense\Mvc\Dispatcher->dispatch(Object(OPNsense\Mvc\Request), Object(OPNsense\Mvc\Response), Object(OPNsense\Mvc\Session))

7 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(139): OPNsense\Mvc\Router->performRequest(Object(OPNsense\Mvc\Dispatcher))

8 /usr/local/opnsense/www/api.php(36): OPNsense\Mvc\Router->routeRequest('/api/nginx/sett...', Array)

9 {main}`

raregtp commented 2 weeks ago

I can confirm the same situation after updating to 24.7.8.

daygle commented 2 weeks ago

Same issue here.

A reinstall of os-nginx did not resolve the issue.

Appears to be related to a compatibility problem with the Phalcon framework used by OPNsense?

WindSow commented 2 weeks ago

Same issue here. After upgrade it show Unexpected error, check log for details. A reinstall of os-nginx did not resolve the issue.

fichtner commented 2 weeks ago

I guess this is an unfortunate side effect of having custom field types/constraints implemented outside the core. A small refactor/fix was made that probably causes the error. But long story short the plugin code needs to be fixed. I’ll take a look.

fichtner commented 2 weeks ago

Let's try this: 1e23572

# opnsense-patch -c plugins 1e23572

Cheers, Franco

pacobattistini commented 2 weeks ago

It worked perfectly for me!! thank you so much for this super fast fix

raregtp commented 2 weeks ago

Working great hear also, thanks!!

twocore commented 2 weeks ago

Works great for me on the too affected instances. That is what i love in open source, fast fixes :+1:

WindSow commented 2 weeks ago

It worked perfectly for me too. Thank you very much

fichtner commented 2 weeks ago

Closing then. Thanks for the feedback and sorry for the hiccup! 😊

homer-simpson commented 2 weeks ago

Thank you, worked for me too!

Nillth commented 2 weeks ago
opnsense-patch -c plugins 1e23572

+1 @fichtner thanks for the speedy fix

marccardinal commented 2 weeks ago

Tested good on two OPNsense appliances 👍

TheRouCo commented 2 weeks ago

Works perfectly!! Thanks!

elliotclee commented 2 weeks ago

Worked for me right now. Didn't even have to restart anything after running the opnsense-patch command.