Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some GET parameters works and others don't #317

Closed
Harryols opened this issue Feb 15, 2023 · 1 comment · Fixed by #324
Closed

Some GET parameters works and others don't #317

Harryols opened this issue Feb 15, 2023 · 1 comment · Fixed by #324
Labels
bug Something isn't working regression Potential regressions that need new tests written

Comments

@Harryols
Copy link

Describe the bug
Some GET parameters works and others don't. (returns no data, even if there)

To Reproduce
Steps to reproduce the behavior:
curl --insecure -u admin:pfsense -X 'GET'
'https://pfsense.examp.net/api/v1/firewall/nat/port_forward/?local-port=80'
-H 'accept: application/json'

Expected behavior
I expected to get the port_forwards containing the GET parameter (?local-port=80)

Screenshots or Response
{"status":"ok","code":200,"return":0,"message":"Success","data":[]}

pfSense Version & Package Version:

  • pfSense Version: 2.6.0-RELEASE (amd64)
  • Package Version: 1.5.1

Affected Endpoints:

  • URL: /api/v1/firewall/nat/port_forward
  • Maybe all

Additional context
Works fine:
curl --insecure -u admin:pfsense -X 'GET'
'https://pfsense.examp.net/api/v1/firewall/nat/port_forward/?target=192.168.1.2'
-H 'accept: application/json'

@jaredhendrickson13 jaredhendrickson13 added bug Something isn't working regression Potential regressions that need new tests written labels Feb 16, 2023
@jaredhendrickson13
Copy link
Owner

Hey!

Looks like this is happening due to the type inference for URL parameters added in feebe80. It's comparing an integer 80 from the request to a string "80" from the pfSense config. This would effect most numeric fields and boolean fields. A work around in the meantime is to use JSON query parameters instead to force the types to match. For example:

curl --insecure -u admin:pfsense -X 'GET' 
'https://pfsense.examp.net/api/v1/firewall/nat/port_forward/' 
-H 'accept: application/json' -d '{"local-port": "80"}'

I'll look into an immediate fix for queries specifically, but a better long term fix is covered by #41 which is planned for v2.

Thanks!

@jaredhendrickson13 jaredhendrickson13 linked a pull request Feb 27, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression Potential regressions that need new tests written
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants