Skip to content

Static Routing PATCH issue #654

@DarkRelayLabs

Description

@DarkRelayLabs

Describe the bug
The API api/v2/routing/static_route results in Response Status: 500 when you try to apply the static routing changes using PATCH method.

To Reproduce

  1. Create a static route using the command below.

curl -k -X POST "https://127.0.0.1/api/v2/routing/static_route"
-H "X-API-Key: <“apikey>
-H "Accept: application/json"
-H "Content-Type: application/json"
-d '{
"id": 0,
"network": "10.0.0.0/18",
"gateway": "WANGW",
"descr": "Static Route for 10.0.0.0/18",
"disabled": false
}'
2) To save the changes send the below Patch request.

curl -k -X PATCH "https://127.0.0.1/api/v2/routing/static_route"
-H "X-API-Key: <“apikey>
-H "Accept: application/json"
-H "Content-Type: application/json"
-d '{
"id": 0,
"network": "10.0.0.0/18",
"gateway": "WANGW",
"descr": "Static Route for 10.0.0.0/18",
"disabled": false
}'

  1. The API response with below error

API Response Data: {"code":500,"status":"internal server error","response_id":"ENDPOINT_RECEIVED_UNEXPECTED_ERROR","message":"array_diff(): Argument #1 ($array) must be of type array, null given\n#0 /usr/local/pkg/RESTAPI/Models/StaticRoute.inc(248): array_diff(NULL, Array)\n#1 /usr/local/pkg/RESTAPI/Models/StaticRoute.inc(172): RESTAPI\Models\StaticRoute->serialize_route()\n#2 /usr/local/pkg/RESTAPI/Core/Model.inc(2128): RESTAPI\Models\StaticRoute->pre_apply_update()\n#3 /usr/local/pkg/RESTAPI/Core/Endpoint.inc(1133): RESTAPI\Core\Model->update(false, false, false)\n#4 /usr/local/pkg/RESTAPI/Core/Endpoint.inc(1026): RESTAPI\Core\Endpoint->patch()\n#5 /usr/local/www/api/v2/routing/static_route/index.php(9): RESTAPI\Core\Endpoint->process_request()\n#6 {main}","data":[]}

Expected behavior
The static routing changes should be saved.

Screenshots or Response

API Response Data: {"code":500,"status":"internal server error","response_id":"ENDPOINT_RECEIVED_UNEXPECTED_ERROR","message":"array_diff(): Argument #1 ($array) must be of type array, null given\n#0 /usr/local/pkg/RESTAPI/Models/StaticRoute.inc(248): array_diff(NULL, Array)\n#1 /usr/local/pkg/RESTAPI/Models/StaticRoute.inc(172): RESTAPI\Models\StaticRoute->serialize_route()\n#2 /usr/local/pkg/RESTAPI/Core/Model.inc(2128): RESTAPI\Models\StaticRoute->pre_apply_update()\n#3 /usr/local/pkg/RESTAPI/Core/Endpoint.inc(1133): RESTAPI\Core\Model->update(false, false, false)\n#4 /usr/local/pkg/RESTAPI/Core/Endpoint.inc(1026): RESTAPI\Core\Endpoint->patch()\n#5 /usr/local/www/api/v2/routing/static_route/index.php(9): RESTAPI\Core\Endpoint->process_request()\n#6 {main}","data":[]}

pfSense Version & Package Version:

  • pfSense Version: 2.7.2-RELEASE (amd64)
  • Package Version v2.3.2

Affected Endpoints:

  • URL: /api/v2/routing/static_route

Additional context
Manually clicking the Apply Changes button in the Pfsense (UI) URL below saves the configuration.
https://127.0.0.1/system_routes.php

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