-
Notifications
You must be signed in to change notification settings - Fork 2.7k
API blocks creation of child region with same name as top-level region, but UI allows it #19302
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
Comments
@yjain18111 @rraj9921 @yash-pal1 I notice you each gave this a 👍 immediately after it was opened. Would one of you like to own it? |
Tried this on NetBox v4.2.8 and it is working fine now, looks like it was fixed, also the error message that was referenced is no longer even in the code. Closing. |
@arthanson I check on v4.2.8 as well as develop branches and this issue exist in both. The error is most likely from DRF rather than netbox code. I suspect something with unique constraint is not working as expected. In any case, this issue must be reopened as the last working version for this issue is v3.7.8. |
Here's a minimal code to reproduce this issue
|
I found the issue is being caused by https://github.com/netbox-community/netbox/blob/main/netbox/dcim/models/sites.py#L49. If you comment this constraint, the API works just as the UI. @arthanson Can you re-confirm? |
@abhi1693 that's weird, your example code works fine on mine and I had originally tried this via the REST API and it worked.
|
@arthanson It looks like you're creating the child region as "Hong Kong" (capitalized), while the parent is "hong kong" (lowercase). There’s a difference between the two:
|
Deployment Type
Self-hosted
NetBox Version
v4.2.3
Python Version
3.10
Steps to Reproduce
Create a new region:Name: Hong Kong, Slug: HK
Name: Hong Kong,Slug: HK (or any valid unique slug),Parent: Hong Kong (the region created in step 1)
Make a POST request to /api/dcim/regions/ with this payload:
{
"name": "Hong Kong",
"slug": "hk-kong",
"parent": <id_of_Hong_Kong_region_created_in _step_1>
}
Expected Behavior
The child region with the same name (Hong Kong) but a different slug should be created successfully under the parent Hong Kong, matching the behavior observed in the UI.
Observed Behavior
The API returns a 400 Bad Request with an error indicating that the name must be unique or conflicts with the parent, even though the UI allows it.
The text was updated successfully, but these errors were encountered: