-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
API endpoint dcim/cables fails to validate termination type against target specified by id #3269
Comments
The endpoint additionally does not check that
|
NetBox v2.5 requires Python 3.5 or higher. Please verify your installation environment. |
My mistake, pulled the python version from the host environment rather than the container it was running in. Updated bug synopsis to reflect correct version of python running the Netbox workers (3.6.8). |
I'm not able to reproduce this on v2.5.13 or v2.6.0. NetBox validates the connection types as expected and returns an error:
Please post the full exact API request you're making to trigger the exception. |
You don't appear to have specified different termination types in your repro attempt. <title>Server Error</title> <body> |
Oh, I see, you're referencing an object that doesn't exist. I would have thought that Django would handle that validation natively but apparently it does not. |
Environment
Steps to Reproduce
POST dcim/cables '{"termination_a_id": "<POWEROUTLET_ID>", "termination_a_type": "<POWERPORT_TYPE_ID>", "termination_b_id": "<POWEROUTLET_ID>", "termination_b_type": "<POWEROUTLET_TYPE_ID>"}'
Expected Behavior
Netbox will validate that an object of "termination_<X>_type" with the specified "termination_<X>_id" actually exists and reject the request with an error if not.
Observed Behavior
Netbox apparently writes the requested data to the dcim_cables table blindly, creating a broken foreign key reference. It does provoke an error, but not a well-formed rejection request, and the cable object gets created anyway:
Server Error
There was a problem with your request. Please contact an administrator. The complete exception is provided below:
<class 'AttributeError'> 'NoneType' object has no attribute 'cable'
The resulting cable object is also "broken" in that it cannot be deleted via the UI or API, as attempts to do so raise an error:
There was a problem with your request. Please contact an administrator. The complete exception is provided below:
<class 'AttributeError'> 'NoneType' object has no attribute 'trace'
Recovery requires deleting the cable directly from the database with a SQL statement.
The text was updated successfully, but these errors were encountered: