You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
f"Failed to get data from NetBox instance {self.nb_url}"
)
Maybe something like this:
ifnotr.status_code==200:
raiseValueError(
f"Failed to get data from NetBox instance {self.nb_url}", r.json()
)
I know that would return a tuple to the user and maybe r.json() doesn't always return data so this probably isn't the best way. But just wanted to give an idea.
My use case is if the user gives an invalid filter. NetBox will return a 400 error like this:
{'site': ['Select a valid choice. TEST is not one of the available choices.']}
So it'd be great to give that feedback to the user.
I can submit a PR if we determine the best method.
The text was updated successfully, but these errors were encountered:
Good point.
Not sure if we can rely on the fact that r.json() will always succeed. AFAIK it will raise an exception if the response body is not valid JSON, for example a plain string.
We could try to append the error message, if the returned Content-Type is "application/json", but I would just dump the raw data instead of first de-serializing it.
Right now if NetBox returns an error, the plugin returns a generic error message that isn't very helpful:
It'd be nice if the plugin returned the error that was given by NetBox here:
nornir_netbox/nornir_netbox/plugins/inventory/netbox.py
Lines 387 to 390 in 860d2f8
Maybe something like this:
I know that would return a tuple to the user and maybe
r.json()
doesn't always return data so this probably isn't the best way. But just wanted to give an idea.My use case is if the user gives an invalid filter. NetBox will return a 400 error like this:
{'site': ['Select a valid choice. TEST is not one of the available choices.']}
So it'd be great to give that feedback to the user.
I can submit a PR if we determine the best method.
The text was updated successfully, but these errors were encountered: