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

OpenVPN Client - Optional fields are required #621

Open
cdevrell opened this issue Dec 20, 2024 · 1 comment
Open

OpenVPN Client - Optional fields are required #621

cdevrell opened this issue Dec 20, 2024 · 1 comment

Comments

@cdevrell
Copy link

cdevrell commented Dec 20, 2024

Describe the bug
When calling a POST or PATCH on the /api/v2/vpn/openvpn/client endpoint, fields which are optional through the PFSense Web UI are required through the API such as local_port or proxy_addr.

To Reproduce
Steps to reproduce the behavior:

  1. Create an OpenVPN client manually in the UI leaving optional fields blank as specified.
  2. Execute a GET command against the /api/v2/vpn/openvpn/client address - the returned json has the following:
{
  "data": {
    ....omitted....
    "interface": "WAN",
    "server_addr": "redacted-address",
    "local_port": "",
    "proxy_addr": "",
    "proxy_port": "",
    ....omitted....
  }
}
  1. Edit some fields in the data object from the JSON response - in my case changing server_addr
  2. Execute a PATCH command using the object from the data reponse, eg:
{
   ....omitted....
   "interface": "WAN",
   "server_addr": "changed-address",
   "local_port": "",
   "proxy_addr": "",
   "proxy_port": "",
   ....omitted....
}

Expected behavior
The OpenVPN Client config is updated with the correct values visable inside the Web UI.

Screenshots or Response
The response:
'{"code":400,"status":"bad request","response_id":"FIELD_EMPTY_NOT_ALLOWED","message":"Field local_port cannot be empty.","data":[]}\n'

The same result happends with a POST command.

I have also tried setting "0" as the value in local_port but this also fails saying a valid TCP or UDP port number must be provided.

Field in the Web UI:
image

pfSense Version & Package Version:

  • pfSense Version: pfSense 2.7.2
  • Package Version v2.3.0

Affected Endpoints:

  • /api/v2/vpn/openvpn/client
@jaredhendrickson13
Copy link
Owner

This occurs because the API does not treat null and empty values as the same like pfSense does. You'll need to use null for these fields to exclude them instead of empty strings. Explicit null values are often required for the API's conditional field components and internal queries to work correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants