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

TypeError: bad operand type for abs(): 'NoneType' #39

Closed
jakubkrysl opened this issue Apr 29, 2022 · 5 comments
Closed

TypeError: bad operand type for abs(): 'NoneType' #39

jakubkrysl opened this issue Apr 29, 2022 · 5 comments
Assignees

Comments

@jakubkrysl
Copy link

Environment

  • Python version: 3.6.15
  • Nautobot version: 1.2.10
  • nautobot-ssot version: 1.1.0

Expected Behavior

SSoT job history shown

Observed Behavior

image

15:35:06.108 ERROR   django.request :
  Internal Server Error: /plugins/ssot/history/7881d7af-7e32-4711-b468-c6a578f5776c/
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/nautobot/utilities/views.py", line 94, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/views/generic/base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/nautobot/core/views/generic.py", line 124, in get
    **self.get_extra_context(request, instance),
  File "/usr/local/lib/python3.6/site-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/usr/local/lib/python3.6/site-packages/django/template/loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "/usr/local/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 170, in render
    return self._render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/defaulttags.py", line 312, in render
    return nodelist.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 988, in render
    output = self.filter_expression.resolve(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 698, in resolve
    new_obj = func(obj, *arg_vals)
  File "/usr/local/lib/python3.6/site-packages/nautobot_ssot/templatetags/humanize_bytes.py", line 20, in humanize_bytes
    if abs(size) < 1024.0:
TypeError: bad operand type for abs(): 'NoneType'

Steps to Reproduce

(not really sure except where it shows)

  1. Run SSoT job with memory profiling
  2. Open history of last run
@chadell chadell self-assigned this May 1, 2022
@chadell
Copy link
Contributor

chadell commented May 1, 2022

hi @Thetacz , I tried to reproduce it with the default Job and I was not able to make it.

Is this happening consistently? is there any other info in the output before opening the history?

One simple workaround on the function would be return 0B if size is None, but it would be better to understand why is failing.

@jakubkrysl
Copy link
Author

hi @chadell, I cannot reproduce it anymore. It was happening consistently with each job running the same code, but since I'm doing a lot of tweaking and those were test jobs, I don't have the exact code and some subsequent change alter on fixed it. The changes happened outside of job class, so it is not in UI.

I'm trying to make parent object access its children and apply their data to itself. This is needed because CustomFields should be implemented as child objects (we have many of those and it is not practical to go with cf_{name} as we would have to define 10-15 for each object type, which does not look clear in the diff), but child objects are supposed to be updated separately. Which won't work, because some of those custom fields are required and I cannot create parent without that data.
I think it might have something to do with me trying to save the parent object to child attribute itself, which I did at one point. This made the whole SSoT ...unstable to put it mildly :)

@jakubkrysl
Copy link
Author

Hi, it started to happen again, though I cannot pinpoint the reproducer. Out of total 6 occurrences (3 now, 3 before), 5 of them happened during loading target adapter and 1 right after starting to calculate diff. I wish I found more relevant info to help you out...

@chadell
Copy link
Contributor

chadell commented May 7, 2022

@Thetacz could you try the latest release v1.1.1, and share what you get?

@chadell
Copy link
Contributor

chadell commented Jun 27, 2022

Fixed by #40

@chadell chadell closed this as completed Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants