configure_snmp_agent: HTTP 500 on OPNsense 26.x, general/set sends fields the plugin's model does not have #36

Closed
opened 2026-10-31 05:53:59 +00:00 by christianmanivong · 0 comments
Owner

Priority: P2 (the SNMP agent setup fails on every OPNsense 26.x firewall).

What

configure_snmp_agent() fails at the configure step against OPNsense 26.7:

[install] os-net-snmp already installed
[configure] 500 Server Error: Internal Server Error for url: https://<firewall>/api/netsnmp/general/set

Why

_write_snmp_agent_config posts

{"general": {"enabled": "1", "community": "…", "contact": "", "location": "",
             "sysobjid": "", "bindip": "", "listen": {"<address>": {"selected": 1}}}}

but GET /api/netsnmp/general/get on 26.7 shows the plugin's model has exactly these fields:
enabled, community, syslocation, syscontact, l3visibility, versionoid, enableagentx, enableobservium, listen.

  • contact / location are syscontact / syslocation.
  • sysobjid and bindip do not exist.
  • listen is a multi-select; the API takes it as a comma-separated string, not the dict shape get returns.

Older releases ignored unknown keys silently, so contact and location were never written; 26.x refuses the request.

Also broken, hidden behind the 500

The step always sends contact and location, as "" when the caller gives none. With the field names corrected it would blank a sysContact/sysLocation the operator set.

Fix

  • Send only fields the model has, under its names, and contact/location only when the caller gives them.
  • listen as a string; "" (no address selected) for a DNS name, which means every address, as before.
Priority: P2 (the SNMP agent setup fails on every OPNsense 26.x firewall). ## What `configure_snmp_agent()` fails at the configure step against OPNsense 26.7: ``` [install] os-net-snmp already installed [configure] 500 Server Error: Internal Server Error for url: https://<firewall>/api/netsnmp/general/set ``` ## Why `_write_snmp_agent_config` posts ```json {"general": {"enabled": "1", "community": "…", "contact": "", "location": "", "sysobjid": "", "bindip": "", "listen": {"<address>": {"selected": 1}}}} ``` but `GET /api/netsnmp/general/get` on 26.7 shows the plugin's model has exactly these fields: `enabled, community, syslocation, syscontact, l3visibility, versionoid, enableagentx, enableobservium, listen`. - `contact` / `location` are `syscontact` / `syslocation`. - `sysobjid` and `bindip` do not exist. - `listen` is a multi-select; the API takes it as a comma-separated string, not the dict shape `get` returns. Older releases ignored unknown keys silently, so contact and location were never written; 26.x refuses the request. ## Also broken, hidden behind the 500 The step always sends contact and location, as `""` when the caller gives none. With the field names corrected it would blank a sysContact/sysLocation the operator set. ## Fix - Send only fields the model has, under its names, and contact/location only when the caller gives them. - `listen` as a string; `""` (no address selected) for a DNS name, which means every address, as before.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-opnsense#36