Skip to content

/api/v1/firewall/nat/outbound/mapping throws error when no mappings exist #385

@jaredhendrickson13

Description

@jaredhendrickson13

Describe the bug
When adding a new outbound NAT mapping to a pfSense instance with no outbound NAT mappings, an error is thrown.

Expected behavior
The outbound NAT mapping should be created.

Screenshots or Response

Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /etc/inc/api/models/APIFirewallNATOutboundMappingCreate.inc:39\nStack trace:\n#0 /etc/inc/api/framework/APIModel.inc(216): APIFirewallNATOutboundMappingCreate->action()\n#1 /etc/inc/api/endpoints/APIFirewallNATOutboundMapping.inc(28): APIModel->call()\n#2 /etc/inc/api/framework/APIEndpoint.inc(63): APIFirewallNATOutboundMapping->post()\n#3 /usr/local/www/api/v1/firewall/nat/outbound/mapping/index.php(3): APIEndpoint->listen()\n#4 {main}\n  thrown in /etc/inc/api/models/APIFirewallNATOutboundMappingCreate.inc on line 39\nPHP ERROR: Type: 1, File: /etc/inc/api/models/APIFirewallNATOutboundMappingCreate.inc, Line: 39, Message: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /etc/inc/api/models/APIFirewallNATOutboundMappingCreate.inc:39\nStack trace:\n#0 /etc/inc/api/framework/APIModel.inc(216): APIFirewallNATOutboundMappingCreate->action()\n#1 /etc/inc/api/endpoints/APIFirewallNATOutboundMapping.inc(28): APIModel->call()\n#2 /etc/inc/api/framework/APIEndpoint.inc(63): APIFirewallNATOutboundMapping->post()\n#3 /usr/local/www/api/v1/firewall/nat/outbound/mapping/index.php(3): APIEndpoint->listen()\n#4 {main}\n  thrown"

pfSense Version & Package Version:

  • pfSense Version: 2.7.0, 23.05
  • Package Version v1.6.1 (pre-v1.6.0 is not effected.)

Affected Endpoints:

  • URL: /api/v1/firewall/nat/outbound/mapping

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions