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

Change error message from API if rack space is already occupied #386

Closed
sirtux opened this issue Apr 28, 2021 · 3 comments · Fixed by #2042
Closed

Change error message from API if rack space is already occupied #386

sirtux opened this issue Apr 28, 2021 · 3 comments · Fixed by #2042
Assignees
Labels
type: bug Something isn't working as expected

Comments

@sirtux
Copy link
Contributor

sirtux commented Apr 28, 2021

Environment

  • Python version: 3.8.5
  • Nautobot version: 1.0.0

Proposed Functionality

When creating a dcim.device via API, and the rack space is already occupied,
an error message should be understandable by the user.

Right now it returns a:

400 Bad Request: {'non_field_errors': ['The fields rack, position, face must make a unique set.']}

which is puzzling and not easy to understand,
I propose to change this to something like:
"Requested rack space is already occupied"

Use Case

A developer will get a better understandable error message and can fix his issue. This took me more than an hour to find out what was going on - granted I could have checked for the rack, but understanding the error would be still useful.

Database Changes

None

External Dependencies

None

@glennmatthews
Copy link
Contributor

Thanks for the report!

Some quick analysis: the "must make a unique set" is the default message returned by Django REST Framework when using a UniqueTogetherValidator, but it looks like there is a message option that can be provided when defining the UniqueTogetherValidator instance to customize this behavior.

@jathanism
Copy link
Contributor

Thanks for the report!

Some quick analysis: the "must make a unique set" is the default message returned by Django REST Framework when using a UniqueTogetherValidator, but it looks like there is a message option that can be provided when defining the UniqueTogetherValidator instance to customize this behavior.

Seeing as that is a default error message from the Django framework core, how could we improve upon it to be more user-friendly? (Open-ended question for anyone who reads this)

@jathanism jathanism added the question Further information is requested label Apr 28, 2021
@itdependsnetworks
Copy link
Contributor

Ideally you can "tack on" without removing the original message. The original message is still helpful, as it provides consistency for this type of issue.

@glennmatthews glennmatthews added workflow: needs clear requirements and removed question Further information is requested labels Aug 24, 2021
@bryanculver bryanculver added the type: bug Something isn't working as expected label Jul 12, 2022
@bryanculver bryanculver self-assigned this Jul 12, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants