Bug when adding model of device after creation
Steps to reproduce
- Create a device, with
-
short name
, e.g.Test device
-
Manufavturer
, e.g.Ackermann KG
Permission Group
-
Visibility
:internal
- Hit
Save
-
- On the
Basic Data
- Tab hitedit
- Add a
Model
- hit
Apply
- hit
- You'll receive an error
-
Note
- If you hit
Apply
again, it will save
- If you hit
Logs
Example Payload
Click to expand
{
"data": {
"type": "device",
"attributes": {
"description": "",
"short_name": "test device 1",
"long_name": "",
"serial_number": "",
"inventory_number": "",
"manufacturer_uri": "http://localhost/cv/api/v1/manufacturers/22/",
"manufacturer_name": "Ackermann KG",
"device_type_uri": "",
"device_type_name": "",
"status_uri": "",
"status_name": "",
"model": "m3",
"persistent_identifier": null,
"website": "",
"is_private": false,
"is_internal": true,
"is_public": false,
"group_ids": [
"1"
],
"keywords": [],
"country": ""
},
"id": "6"
}
}
Backend Logs
Click to expand
sms_backend | [2024-06-19 11:14:55 +0000] [1004] [DEBUG] PATCH /backend/api/v1/devices/5
sms_backend | [2024-06-19 11:14:55 +0000] [1004] [ERROR] Error handling request /backend/api/v1/devices/5
sms_backend | Traceback (most recent call last):
sms_backend | File "/usr/local/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 135, in handle
sms_backend | self.handle_request(listener, req, client, addr)
sms_backend | File "/usr/local/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 178, in handle_request
sms_backend | respiter = self.wsgi(environ, resp.start_response)
sms_backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 2091, in __call__
sms_backend | return self.wsgi_app(environ, start_response)
sms_backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/src/app/project/wsgimiddleware/__init__.py", line 40, in __call__
sms_backend | return self.wsgi_app(environ, start_response)
sms_backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/werkzeug/middleware/proxy_fix.py", line 182, in __call__
sms_backend | return self.app(environ, start_response)
sms_backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 2076, in wsgi_app
sms_backend | response = self.handle_exception(e)
sms_backend | ^^^^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask_cors/extension.py", line 176, in wrapped_function
sms_backend | return cors_after_request(app.make_response(f(*args, **kwargs)))
sms_backend | ^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 2073, in wsgi_app
sms_backend | response = self.full_dispatch_request()
sms_backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1519, in full_dispatch_request
sms_backend | rv = self.handle_user_exception(e)
sms_backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask_cors/extension.py", line 176, in wrapped_function
sms_backend | return cors_after_request(app.make_response(f(*args, **kwargs)))
sms_backend | ^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1517, in full_dispatch_request
sms_backend | rv = self.dispatch_request()
sms_backend | ^^^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1503, in dispatch_request
sms_backend | return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
sms_backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/src/app/project/api/token_checker.py", line 32, in wrapper
sms_backend | return fn(*args, **kwargs)
sms_backend | ^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask_rest_jsonapi/decorators.py", line 47, in wrapper
sms_backend | return func(*args, **kwargs)
sms_backend | ^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask/views.py", line 84, in view
sms_backend | return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
sms_backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask_rest_jsonapi/decorators.py", line 77, in wrapper
sms_backend | return func(*args, **kwargs)
sms_backend | ^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask_rest_jsonapi/resource.py", line 73, in dispatch_request
sms_backend | response = method(*args, **kwargs)
sms_backend | ^^^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask_rest_jsonapi/decorators.py", line 77, in wrapper
sms_backend | return func(*args, **kwargs)
sms_backend | ^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask_rest_jsonapi/api.py", line 180, in decorated
sms_backend | return view(*view_args, **view_kwargs)
sms_backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask_rest_jsonapi/decorators.py", line 68, in wrapper
sms_backend | return func(*args, **kwargs)
sms_backend | ^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/local/lib/python3.11/site-packages/flask_rest_jsonapi/resource.py", line 302, in patch
sms_backend | final_result = self.after_patch(result)
sms_backend | ^^^^^^^^^^^^^^^^^^^^^^^^
sms_backend | File "/usr/src/app/project/api/resources/device_resources.py", line 279, in after_patch
sms_backend | existing_manufacturer_model.external_system_name,
sms_backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sms_backend | AttributeError: 'NoneType' object has no attribute 'external_system_name'
Attachment
Edited by Tobias Kuhnert