core icon indicating copy to clipboard operation
core copied to clipboard

Updating one-to-one NAT & NPTv6 rule leads to "Unexpected error, check log for details" error

Open RyanNgWH opened this issue 6 months ago • 1 comments

Important notices

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

  • [x] I have read the contributing guide lines at https://github.com/opnsense/core/blob/master/CONTRIBUTING.md
  • [x] I am convinced that my issue is new after having checked both open and closed issues at https://github.com/opnsense/core/issues?q=is%3Aissue

Describe the bug

When attempting to edit a one-to-one NAT or NPTv6 rule (even with no actual changes made to the configuration), I get an error stating Unexpected error, check log for details. A crash report is generated with the details added in the relevant log files section below.

This error occurs in the following scenarios:

  1. Updating Firewall > Automation > Filter rules (Rules do not seem to show & + button on GUI does not seem to do anything - can only create and get rules from the API)
  2. Creating Firewall > Automation > Source NAT rules
  3. Updating Firewall > NAT > NPTv6 rules
  4. Updating Firewall > NAT > One-to-One rules

To Reproduce

Steps to reproduce the behavior:

  1. Go to Firewall > NAT > NPTv6
  2. Create a new rule and save
  3. Click on edit for the newly created rule
  4. Click on Save
  5. Error appears & crash report generated

Expected behavior

To be able to create/edit rules without any issues.

Describe alternatives you considered

None.

Screenshots

None.

Relevant log files

System Information:

User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0
FreeBSD 14.2-RELEASE-p3 stable/25.1-n269825-cbaf3aa6b26b SMP amd64
OPNsense 25.1.8_1 74f397e13
Plugins os-qemu-guest-agent-1.3
Time Mon, 16 Jun 2025 00:08:08 +0800
OpenSSL 3.0.16
Python 3.11.12
PHP 8.3.21

PHP Error:

[16-Jun-2025 00:08:04 Asia/Singapore] Error: Call to a member function isEmpty() on null in /usr/local/opnsense/mvc/app/models/OPNsense/Firewall/Filter.php:95
Stack trace:
#0 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(273): OPNsense\Firewall\Filter->performValidation(true)
#1 /usr/local/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php(571): OPNsense\Base\ApiMutableModelControllerBase->validate(Object(OPNsense\Firewall\FieldTypes\SourceNatRuleContainerField), 'rule', true)
#2 /usr/local/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/NptController.php(50): OPNsense\Base\ApiMutableModelControllerBase->setBase('rule', 'npt.rule', '7be570f2-8f0e-4...')
#3 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Dispatcher.php(166): OPNsense\Firewall\Api\NptController->setRuleAction('7be570f2-8f0e-4...')
#4 /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))
#5 /usr/local/opnsense/mvc/app/library/OPNsense/Mvc/Router.php(139): OPNsense\Mvc\Router->performRequest(Object(OPNsense\Mvc\Dispatcher))
#6 /usr/local/opnsense/www/api.php(36): OPNsense\Mvc\Router->routeRequest('/api/firewall/n...', Array)
#7 {main}

Additional context

None.

Environment

Software version used and hardware type if relevant, e.g.:

OPNsense 25.1.8_1 (amd64).

RyanNgWH avatar Jun 15 '25 16:06 RyanNgWH

I expect it’s https://github.com/opnsense/core/commit/384945129fae149c994dfd8b2c33b3e6f814cd8a, noticed the same on my end last week

AdSchellevis avatar Jun 16 '25 06:06 AdSchellevis

I had the same error when trying to add an entry to Firewall > Automation > Source NAT. I updated from OPNsense 25.1.7_4-amd64 to OPNsense 25.1.10-amd64 and that has resolved the error 👍

soupdiver avatar Jul 03 '25 09:07 soupdiver