Skip to content

ASN API Internal Server Error: duplicate key value violates unique constraint "uniqie_number" #32

@k01ek

Description

@k01ek

NetBox version
2.11.3

Describe the bug
When trying to create an ASN object via API which already exists and tenant is None, the following error occurs:

IntegrityError at /api/plugins/bgp/asn/
duplicate key value violates unique constraint "uniqie_number"
DETAIL:  Key (number)=(1) already exists.


Request Method: POST
Request URL: http://0.0.0.0:8000/api/plugins/bgp/asn/
Django Version: 3.2
Python Executable: /usr/local/bin/python
Python Version: 3.7.7
...

To Reproduce
Steps to reproduce the behavior:

  1. Go to http://0.0.0.0:8000/api/docs/
  2. POST New ASN with data:
{
  "number": 1,
  "status": "active",
  "description": "string"
}
  1. Repeat step №2
  2. See error

Expected behavior
API should return 400 Error: Bad Request with body:

{
  "__all__": [
    "Asn with this Number and Tenant already exists."
  ]
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions