Snmp defaults when adding device via api

It would be nice if you didn’t have to specify snmp credentials when adding a device via the API. LibreNMS should attempt to use the credentials configured in the global configuration to connect. For example, add device, attempt to connect with V1/community, attempt to connect with v2c/community, V3/user until it finds a match. This same functionality should exist in the UI if you don’t specify a community in the add device page.

I was pretty sure it didn’t require credentials. (It uses the same code paths)
If there is an issue it is in the API code.

I’ve tried via the API and the UI. The only way I’ve seen it actually not require the credentials is with auto discovery via xdp or the snmp scanner script. If I don’t specify the snmpver parameter I get an error back saying it has to be included. And if I include snmpver but no credentials the device is added as long as I do a force_add but the credentials aren’t set so it just shows as down until I manually add credentials in the UI. Maybe there’s some other piece I’m missing?

Okay, after further testing it looks like if you use the force_add it doesn’t work, as I’m guessing it bypasses the discovery checks? In my environment though I’m usually adding a device to a specific remote poller and the main server doesn’t have direct access to ping the device during the pre-checks. Is there another way to accomplish this and have it work without specifying the credentials?

Also, the API response likely should not return the SNMP credentials, I feel like that’s a potential security risk in logs and stuff.

Force add:
Body: {
“hostname”: “10.242.50.2”,
“display”: “librenmsdev”,
“location”: “test”,
“force_add”: “TRUE”
}

Response:
{
“status”: “error”,
“message”: “SNMP information is required when force adding a device”
}

Based on the docs this should not require credentials?