AttributeError returned with Selection Custom Field and Webhook Enabled #4080

Closed
opened 2025-12-29 18:33:00 +01:00 by adam · 0 comments
Owner

Originally created by @WilliamMarti on GitHub (Sep 8, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

Python version: 3.6.9
NetBox version: 2.9.3

Steps to Reproduce

  1. Create custom field called "bugreport" of type Selection with options apple, orange, banana
  2. Find the IDs of the choices we just made
curl --request GET \
  --url https://netbox.example.com/api/extras/_custom_field_choices/ \
  --header 'accept: application/json' \
  --header 'authorization: Token $token' \
  --header 'content-type: application/json' \

In my case this is: 67,69,68

  1. Create a fresh Prefix to assign an IP in:
curl --request POST \
  --url https://netbox.example.com/api/ipam/prefixes/ \
  --header 'accept: application/json' \
  --header 'authorization: Token $token' \
  --header 'content-type: application/json' \
  --data '{
  "prefix": "10.10.10.0/24"
}'
  1. Make sure the Webhook for the IPAddress object is enabled

  2. Make a request to assign an IP in the above create Prefix, with one of the custom options found above. In this case the Prefix ID is 11913

curl --request POST \
  --url https://netbox.example.com/api/ipam/prefixes/11913/available-ips/ \
  --header 'accept: application/json' \
  --header 'authorization: Token $token' \
  --header 'content-type: application/json' \
  --data '{
  "description": "testserver1",
  "custom_fields": {
    "bugreport": 67
  }
}'

Expected Behavior

IP Address to be assigned with a custom field, of the Selection type, filled out

Observed Behavior

Get the following error

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Server Error</title>
    <link rel="stylesheet" href="/static/bootstrap-3.4.1-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="/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>&lt;class &#x27;AttributeError&#x27;&gt;</strong><br />
Got AttributeError when attempting to get a value for field `value` on serializer `CustomFieldChoiceSerializer`.
The serializer field might be named incorrectly and not match any attribute or key on the `int` instance.
Original exception text was: &#x27;int&#x27; object has no attribute &#x27;pk&#x27;.

Python version: 3.6.9
NetBox version: 2.9.2</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="/" class="btn btn-primary">Home Page</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

Note that this is a re-open of #5029, and looks to be related to #5081. Based on the advice in #5081, I have tried restarting my netbox-rqworker service but still seem to be getting the same issue. Disabling the IPAddress Webhook is still a work around.

If there is anything else I can provide please let me know

Originally created by @WilliamMarti on GitHub (Sep 8, 2020). Originally assigned to: @jeremystretch on GitHub. ### Environment Python version: 3.6.9 NetBox version: 2.9.3 ### Steps to Reproduce 1. Create custom field called "bugreport" of type Selection with options apple, orange, banana 2. Find the IDs of the choices we just made ``` curl --request GET \ --url https://netbox.example.com/api/extras/_custom_field_choices/ \ --header 'accept: application/json' \ --header 'authorization: Token $token' \ --header 'content-type: application/json' \ ``` In my case this is: 67,69,68 3. Create a fresh Prefix to assign an IP in: ``` curl --request POST \ --url https://netbox.example.com/api/ipam/prefixes/ \ --header 'accept: application/json' \ --header 'authorization: Token $token' \ --header 'content-type: application/json' \ --data '{ "prefix": "10.10.10.0/24" }' ``` 4. Make sure the Webhook for the IPAddress object is enabled 5. Make a request to assign an IP in the above create Prefix, with one of the custom options found above. In this case the Prefix ID is 11913 ``` curl --request POST \ --url https://netbox.example.com/api/ipam/prefixes/11913/available-ips/ \ --header 'accept: application/json' \ --header 'authorization: Token $token' \ --header 'content-type: application/json' \ --data '{ "description": "testserver1", "custom_fields": { "bugreport": 67 } }' ``` ### Expected Behavior IP Address to be assigned with a custom field, of the Selection type, filled out ### Observed Behavior Get the following error ``` <!DOCTYPE html> <html lang="en"> <head> <title>Server Error</title> <link rel="stylesheet" href="/static/bootstrap-3.4.1-dist/css/bootstrap.min.css"> <link rel="stylesheet" href="/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>&lt;class &#x27;AttributeError&#x27;&gt;</strong><br /> Got AttributeError when attempting to get a value for field `value` on serializer `CustomFieldChoiceSerializer`. The serializer field might be named incorrectly and not match any attribute or key on the `int` instance. Original exception text was: &#x27;int&#x27; object has no attribute &#x27;pk&#x27;. Python version: 3.6.9 NetBox version: 2.9.2</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="/" class="btn btn-primary">Home Page</a> </div> </div> </div> </div> </div> </div> </body> </html> ``` Note that this is a re-open of #5029, and looks to be related to #5081. Based on the advice in #5081, I have tried restarting my netbox-rqworker service but still seem to be getting the same issue. Disabling the IPAddress Webhook is still a work around. If there is anything else I can provide please let me know
adam added the type: bugstatus: accepted labels 2025-12-29 18:33:00 +01:00
adam closed this issue 2025-12-29 18:33:00 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4080