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

Can not add image to device type #13845

Closed
whtkam opened this issue Sep 21, 2023 · 5 comments · Fixed by #13851
Closed

Can not add image to device type #13845

whtkam opened this issue Sep 21, 2023 · 5 comments · Fixed by #13851
Assignees
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@whtkam
Copy link

whtkam commented Sep 21, 2023

NetBox version

v3.6.2

Python version

3.8

Steps to Reproduce

  1. create new device-type
  2. add image to Front image
  3. save

Expected Behavior

save image to device-type

Observed Behavior

<class 'AttributeError'>

'str' object has no attribute 'delete'

Python version: 3.8.10
NetBox version: 3.6.2
Plugins:
netbox_demo: 0.3.1

@whtkam whtkam added the type: bug A confirmed report of unexpected behavior in the application label Sep 21, 2023
@abhi1693 abhi1693 added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: medium Results in substantial degraded or broken functionality for specfic workflows labels Sep 21, 2023
@Azmodeszer
Copy link
Contributor

Azmodeszer commented Sep 21, 2023

Can confirm.

Python version: 3.9.2
NetBox version: 3.6.2

@jeremystretch
Copy link
Member

@arthanson can you look into this please? Seems we need to update the logic for deleting the old front/rear images under save().

Traceback (most recent call last):
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/jstretch/projects/netbox/netbox/netbox/views/generic/object_views.py", line 170, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/home/jstretch/projects/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/home/jstretch/projects/netbox/netbox/utilities/views.py", line 99, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 143, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/jstretch/projects/netbox/netbox/netbox/views/generic/object_views.py", line 264, in post
    obj = form.save()
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/forms/models.py", line 542, in save
    self.instance.save()
  File "/home/jstretch/projects/netbox/netbox/dcim/models/devices.py", line 336, in save
    self._original_front_image.delete(save=False)

Exception Type: AttributeError at /dcim/device-types/11/edit/
Exception Value: 'str' object has no attribute 'delete'

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Sep 21, 2023
@leandrosly
Copy link

Confirmed.

<class 'AttributeError'>

'str' object has no attribute 'delete'

Python version: 3.8.10
NetBox version: 3.6.2
Plugins: None installed

@leandrosly
Copy link

leandrosly commented Sep 21, 2023

Definitely not a solution but i tried commenting lines 335 to 338 in /opt/netbox/netbox/dcim/models/devices.py and was able to upload the image.

def save(self, *args, **kwargs):
    ret = super().save(*args, **kwargs)

    # Delete any previously uploaded image files that are no longer in use
    #if self.front_image != self._original_front_image:
    #    self._original_front_image.delete(save=False)
    #if self.rear_image != self._original_rear_image:
    #    self._original_rear_image.delete(save=False)

    return ret

@mike548141
Copy link

I see there is a PR to fix this, thank you. In case its helpful I can reproduce this bug on my docker install, the exception message is
`<class 'AttributeError'>

'str' object has no attribute 'delete'

Python version: 3.11.4
NetBox version: 3.6.2
Plugins: None installed`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
7 participants