Skip to content

Internal server error on PATCH request to device bay #3596

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

Closed
ajknv opened this issue Oct 11, 2019 · 3 comments
Closed

Internal server error on PATCH request to device bay #3596

ajknv opened this issue Oct 11, 2019 · 3 comments
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@ajknv
Copy link
Contributor

ajknv commented Oct 11, 2019

Environment

  • Python version: 3.6.8
  • NetBox version: 2.6.3

Steps to Reproduce

  1. Make a PATCH request API endpoint "dcim/device-bays" to install a child device.
  2. Make another PATCH request to "dcim/device-bays" with a different device-bay ID but the same "installed_device" id for the child device.

Expected Behavior

Installing the same child device twice into separate device bays can be reasonably viewed as an error, but the error should be a graceful application error of some kind rather than an internal server error. (Alternately/debatably the request could be treated as a movement of the child device from one bay to another.)

Observed Behavior

An internal server error tracing a duplicate key violation exception:

Exception: HTTP error 500 (Internal Server Error) - 
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Server Error</title>
    <link rel="stylesheet" href="https://github.com/static/bootstrap-3.4.1-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://github.com/static/font-awesome-4.7.0/css/font-awesome.min.css">
    <meta charset="UTF-8">
</head>

<body>
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-6 col-md-offset-3">
                <div class="panel panel-danger" style="margin-top: 200px">
                    <div class="panel-heading">
                        <strong>
                            <i class="fa fa-warning"></i>
                            Server Error
                        </strong>
                    </div>
                    <div class="panel-body">
                        
                            <p>
                                There was a problem with your request. Please contact an administrator.
                            </p>
                        
                        <hr />
                        <p>
                            The complete exception is provided below:
                        </p>
<pre><strong><class &#39;django.db.utils.IntegrityError&#39;></strong><br />
duplicate key value violates unique constraint &quot;dcim_devicebay_installed_device_id_key&quot;
DETAIL:  Key (installed_device_id)=(3205) already exists.
</pre>
                        <p>
                            If further assistance is required, please post to the <a href="https://groups.google.com/forum/#!forum/netbox-discuss">NetBox mailing list</a>.
                        </p>
                        <div class="text-right">
                            <a href="https://github.com/" class="btn btn-primary">Home Page</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>
@DanSheps
Copy link
Member

Hello,

I am unable to reproduce this on https://master.netbox.dansheps.com/:

  • Create Device PD1
  • Create Device CD1
  • Perform the below API operations:
curl -X PATCH "https://master.netbox.dansheps.com/api/dcim/device-bays/1/" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"installed_device\": 84}"
curl -X PATCH "https://master.netbox.dansheps.com/api/dcim/devices/84/" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"comments\": \"Test\"}"
curl -X PATCH "https://master.netbox.dansheps.com/api/dcim/device-bays/1/" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"installed_device\": 84}"

This does not present any error. Could you please provide reproducible steps?

@DanSheps DanSheps added the status: revisions needed This issue requires additional information to be actionable label Oct 17, 2019
@ajknv
Copy link
Contributor Author

ajknv commented Oct 18, 2019

Revised the issue description. Turns out the failure was triggered by trying to install the same child device into two different device bays. More of a logical error now, of course, but it could still be handled more gracefully.

@DanSheps
Copy link
Member

Thanks for confirming ajknv, I do agree that it should be a proper API error message, instead of what you are receiving.

@DanSheps DanSheps added status: accepted This issue has been accepted for implementation type: housekeeping Changes to the application which do not directly impact the end user type: bug A confirmed report of unexpected behavior in the application and removed status: revisions needed This issue requires additional information to be actionable type: housekeeping Changes to the application which do not directly impact the end user labels Oct 18, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 22, 2020
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

2 participants