jaredhendrickson13 / pfsense-api

The missing REST and GraphQL API package for pfSense
https://pfrest.org/
Apache License 2.0
685 stars 106 forks source link

Response code 500 when calling /api/v2/firewall/nat/one_to_one/mappings #491

Closed hirosumee closed 4 months ago

hirosumee commented 4 months ago

Describe the bug When tried to call /api/v2/firewall/nat/one_to_one/mappings endpoint , i faced the below 500 response code { "code": 500, "status": "internal server error", "response_id": "ENDPOINT_RECEIVED_UNEXPECTED_ERROR", "message": "Named parameter $parent_id overwrites previous argument\n#0 /usr/local/pkg/RESTAPI/Core/Model.inc(1554): RESTAPI\\Models\\OneToOneNATMapping->__construct(parent_id: NULL)\n#1 /usr/local/pkg/RESTAPI/Core/Model.inc(1737): RESTAPI\\Core\\Model::read_all(NULL, 0, 0)\n#2 /usr/local/pkg/RESTAPI/Core/Endpoint.inc(742): RESTAPI\\Core\\Model::query(Array, Array, NULL, 0, 0)\n#3 /usr/local/pkg/RESTAPI/Core/Endpoint.inc(688): RESTAPI\\Core\\Endpoint->get()\n#4 /usr/local/www/api/v2/firewall/nat/one_to_one/mappings/index.php(3): RESTAPI\\Core\\Endpoint->process_request()\n#5 {main}", "data": [] }

To Reproduce Steps to reproduce the behavior:

  1. Call API /api/v2/firewall/nat/one_to_one/mappings
  2. See error

Expected behavior Return list of one_to_one mapping list

Screenshots or Response

image

pfSense Version & Package Version:

Affected Endpoints:

Additional context

jaredhendrickson13 commented 4 months ago

Thanks for reporting this, I'll push out a fix today.

jaredhendrickson13 commented 4 months ago

The latest release candidate build contains a fix for this as well as new tests to ensure it doesn't pop up again:

https://github.com/jaredhendrickson13/pfsense-api/releases/tag/v2.0.0-rc-217e88f