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

'CircuitTermination' object has no attribute 'name' #5626

Closed
mickaelmonsieur opened this issue Jan 14, 2021 · 11 comments
Closed

'CircuitTermination' object has no attribute 'name' #5626

mickaelmonsieur opened this issue Jan 14, 2021 · 11 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@mickaelmonsieur
Copy link

Environment

  • Python version: "3.7.3"
  • NetBox version: "2.10.3"

Steps to Reproduce

On the API, in the page 3 i have this error 500:

"Got AttributeError when attempting to get a value for field `name` on serializer `NestedInterfaceSerializer`.\nThe serializer field might be named incorrectly and not match any attribute or key on the `CircuitTermination` instance.\nOriginal exception text was: 'CircuitTermination' object has no attribute 'name'."

URL called is : https://netbox/api/circuits/circuits/?cf_technology=VDSL&offset=100&type=s-internet-over-best-effort-line

I have 167 circuits that match my search. Only part 100 - 150 does not work.

This URL works :

URL called is : https://netbox/api/circuits/circuits/?cf_technology=VDSL&type=s-internet-over-best-effort-line
URL called is : https://netbox/api/circuits/circuits/?cf_technology=VDSL&offset=50&type=s-internet-over-best-effort-line
URL called is : https://netbox/api/circuits/circuits/?cf_technology=VDSL&offset=150&type=s-internet-over-best-effort-line

@mickaelmonsieur mickaelmonsieur changed the title CircuitTermination' object has no attribute 'name' 'CircuitTermination' object has no attribute 'name' Jan 14, 2021
@DanSheps
Copy link
Member

Can you post reliable steps to recreate, starting from creating the object required for this to work (circuit, device, etc)

@DanSheps DanSheps added the status: revisions needed This issue requires additional information to be actionable label Jan 14, 2021
@mickaelmonsieur
Copy link
Author

Can you be more precise?
This circuit API query has +150 results, I don't know which circuit is causing this API error. The only message I have, I have already given.

@jeremystretch
Copy link
Member

We can only accept bug reports that can be independently reproduced by another party. Per the issue template, please specify the exact steps someone else can take to reproduce the reported behavior on a separate instance of the latest stable release of NetBox. This includes the creation of the necessary circuits and their related objects.

@j-munroe
Copy link

Folks, I'm getting the exact same issue as well that started after my to 2.10.3. My issue is repeatable and re-producible. This has been working consistently fine from the 2.8.x days of Netbox.

In my case I'm doing a URI query against Netbox to gather circuit info into vars via ansible. The call is simple: {{ netbox }}/api/circuits/circuits/?limit=0

TASK [build_vars : Query Netbox circuits api for all circuits.] ****************
fatal: [localhost]: FAILED! => {"api_version": "2.10", "attempts": 3, "changed": false, "connection": "close", "content": "{"error": "Got AttributeError when attempting to get a value for field name on serializer NestedInterfaceSerializer.\nThe serializer field might be named incorrectly and not match any attribute or key on the CircuitTermination instance.\nOriginal exception text was: 'CircuitTermination' object has no attribute 'name'.", "exception": "AttributeError", "netbox_version": "2.10.3", "python_version": "3.6.9"}", "content_length": "413", "content_type": "application/json", "date": "Fri, 15 Jan 2021 12:24:36 GMT", "elapsed": 1, "json": {"error": "Got AttributeError when attempting to get a value for field name on serializer NestedInterfaceSerializer.\nThe serializer field might be named incorrectly and not match any attribute or key on the CircuitTermination instance.\nOriginal exception text was: 'CircuitTermination' object has no attribute 'name'.", "exception": "AttributeError", "netbox_version": "2.10.3", "python_version": "3.6.9"}, "msg": "Status code was 500 and not [200]: HTTP Error 500: Internal Server Error", "redirected": false, "referrer_policy": "same-origin", "server": "nginx", "status": 500, "url": "https://xxxxxx.xxxxx.xx/api/circuits/circuits/?limit=0", "vary": "Cookie, Origin", "x_content_type_options": "nosniff", "x_frame_options": "sameorigin"}

@jeremystretch
Copy link
Member

My issue is repeatable and re-producible.

Great. Please detail the steps by which it can be reproduced, as I requested above. Just pointing to a REST API endpoint and pasting the output of an Ansible job isn't enough to reproduce the bug.

@mickaelmonsieur
Copy link
Author

My issue is repeatable and re-producible.

Great. Please detail the steps by which it can be reproduced, as I requested above. Just pointing to a REST API endpoint and pasting the output of an Ansible job isn't enough to reproduce the bug.

Have you tried at least?
For my part, if I make a call {{ netbox }}/api/circuits/circuits/?limit=0 as reported by @j-munroe, I have the error.

@j-munroe
Copy link

Hi @jeremystretch,

I removed all external components. Steps to reproduce:

  1. Run curl against Netbox API for the call https://{{ netbox_url}}/api/circuits/circuits/?limit=0

$ curl -H "Authorization: Token xxxxxxxxxxxxxxxxxxx" -H "Accept: application/json; indent=4" https://{{ netbox_url}}/api/circuits/circuits/?limit=0 | jq '.'

  1. Get the results :-)

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 413 100 413 0 0 297 0 0:00:01 0:00:01 --:--:-- 297
{
"error": "Got AttributeError when attempting to get a value for field name on serializer NestedInterfaceSerializer.\nThe serializer field might be named incorrectly and not match any attribute or key on the CircuitTermination instance.\nOriginal exception text was: 'CircuitTermination' object has no attribute 'name'.",
"exception": "AttributeError",
"netbox_version": "2.10.3",
"python_version": "3.6.9"
}

  1. You can repeat this every second and the results are the same.

Hope this helps!

Jim

@jeremystretch
Copy link
Member

Have you tried at least?

I have, and it was not reproducible, hence the request for more information. But you don't have to take my word for it: our CI test for this endpoint also doesn't trigger the bug. So, there's probably something about your specific configuration or data that's causing it. This is why the issue template states:

Describe in detail the exact steps that someone else can take to reproduce
this bug using the current stable release of NetBox. Begin with the
creation of any necessary database objects and call out every operation
being performed explicitly.

I'd like to help you, but can't unless you give me more information to work with.

@j-munroe
Copy link

This isn't a very scientific explanation. But I started trying to narrow down the particular circuit/provider by querying the API based on the provider_id:

https://{{netbox_url}}/api/circuits/circuits/?provider_id={{id}}

There was one provider with a Termination - Z Side cable connection to a circuit on another provider circuit (A provider1 , B provider2). I deleted the cable id # and low and behold the api error disappeared.

Privately @jeremystretch I can share the before and after netbox db sql dumps if you'd like?

@Hedius
Copy link
Contributor

Hedius commented Jan 26, 2021

Environment

  • Python version: "3.9.1" (also happens on 3.7)
  • NetBox version: "2.10.3"

Hello.
Clean/Empty installation.
Maybe less steps are needed, but our setup for this issue looks exactly like this.

Steps to Reproduce

  1. Create Provider1

  2. Create Provider2

  3. Create Tenant1

  4. Create Tenant2

  5. Create Site1

  6. Create Device Role: Cable Management

  7. Create Manufacturer1

  8. Create Device Type: housing-panel
    -- Manufacturer1
    -- Height 1U

  9. Create Device Tray1
    -- Role: Cable Management
    -- Device Type: housing-panel
    -- Site: Site1
    -- Tenant: Tenant1

  10. Add a rear port: Rear Port 1
    -- Type: LC/APC

  11. Add a front port: Front Port 1
    -- Type: LC/APC
    -- Assign the rear port

  12. Create a Circuit Type: CircuitType1

  13. Add Circuit1
    -- Provider: Provider1
    -- Type: CircuitType1
    -- Tenant: Tenant1

  14. Add Circuit2
    -- Provider: Provider2
    -- Type: CircuitType1
    -- Tenant: Tenant2

  15. Add a Z side to Circuit1
    -- Site: Site1
    -- 100Gbps up/down

  16. Add a Z side to Circuit2
    -- Site: Site1
    -- 100Gbps up/down

  17. Cable the Z side of Circuit1 to the device tray1 (Front Port 1)

  18. Cable the Z side of Circuit2 to the device tray1 (Rear Port 1)

The setup should look like this:
581a1e4c-3b14-43d3-92ad-574fd5cb2956

Expected Behavior

The following queries should not fail:
/api/circuits/circuits/2/
/api/circuits/circuits/1/
/api/circuits/circuits/

Observed Behavior

After doing this, opening both circuits via the API will fail:
{"error": "Got AttributeError when attempting to get a value for field `name` on serializer `NestedInterfaceSerializer`.\nThe serializer field might be named incorrectly and not match any attribute or key on the `CircuitTermination` instance.\nOriginal exception text was: 'CircuitTermination' object has no attribute 'name'.", "exception": "AttributeError", "netbox_version": "2.10.3", "python_version": "3.9.1"}

Queries that will fail:
/api/circuits/circuits/2/
/api/circuits/circuits/1/
/api/circuits/circuits/

Conclusion

The problem is caused by the cables (maybe). Removing a cable will fix the problem for the now unplugged circuit.

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application and removed status: revisions needed This issue requires additional information to be actionable labels Feb 8, 2021
@jeremystretch jeremystretch self-assigned this Feb 8, 2021
@jeremystretch
Copy link
Member

Thank you @Hedius for taking the time to provide a detailed reproduction script per the issue template. Using the information you provided, I was able to replicate the reported bug, and can now work on fixing it.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

5 participants