Skip to content

Recursive API query not working as designed #72

@jaredhendrickson13

Description

@jaredhendrickson13

When querying recursively without a filter, the query will always return empty. This should return all objects matching the query exactly. To replicate:

  1. If I read all firewall rules I see there are rules that will match my query source__network=lan
curl -k -s -d '{"client-id": "admin", "client-token": "pfsense"}' -X GET "https://172.16.209.9/api/v1/firewall/rule" | jq .
{
  "status": "ok",
  "code": 200,
  "return": 0,
  "message": "Success",
  "data": [
    {
      "type": "pass",
      "ipprotocol": "inet",
      "descr": "Default allow LAN to any rule",
      "interface": "lan",
      "tracker": "0100000101",
      "source": {
        "network": "lan"
      },
      "destination": {
        "any": ""
      }
    },
    {
      "type": "pass",
      "ipprotocol": "inet6",
      "descr": "Default allow LAN IPv6 to any rule",
      "interface": "lan",
      "tracker": "0100000102",
      "source": {
        "network": "lan"
      },
      "destination": {
        "any": ""
      }
    },
    {
      "tracker": "1606766007",
      "type": "pass",
      "interface": "wan",
      "ipprotocol": "inet46",
      "statetype": "keep state",
      "os": "",
      "source": {
        "any": ""
      },
      "destination": {
        "any": ""
      },
      "descr": "Allow all ipv4+ipv6 via pfSsh.php",
      "created": {
        "time": "1606766007",
        "username": "pfSsh.php added allow all wan rule"
      }
    }
  ]
}
  1. when I rerun the call including my query parameter, I get no matched objects in the return.
curl -k -s -d '{"source__network": "lan", "client-id": "admin", "client-token": "pfsense"}' -X GET "https://172.16.209.9/api/v1/firewall/rule" | jq .
{
  "status": "ok",
  "code": 200,
  "return": 0,
  "message": "Success",
  "data": []
}
  1. If I rerun the same call with the contains filter on my query, I get the expected result
curl -k -s -d '{"source__network__contains": "lan", "client-id": "admin", "client-token": "pfsense"}' -X GET "https://172.16.209.9/api/v1/firewall/rule" | jq .
{
  "status": "ok",
  "code": 200,
  "return": 0,
  "message": "Success",
  "data": [
    {
      "type": "pass",
      "ipprotocol": "inet",
      "descr": "Default allow LAN to any rule",
      "interface": "lan",
      "tracker": "0100000101",
      "source": {
        "network": "lan"
      },
      "destination": {
        "any": ""
      }
    },
    {
      "type": "pass",
      "ipprotocol": "inet6",
      "descr": "Default allow LAN IPv6 to any rule",
      "interface": "lan",
      "tracker": "0100000102",
      "source": {
        "network": "lan"
      },
      "destination": {
        "any": ""
      }
    }
  ]
}

This is problematic as the only way to match an exact query is to specify the query with no filter. Since this is a framework component this is likely to effect all GET supported endpoints that return multiple objects.

Metadata

Metadata

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