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

[1.3.10rc2] Exception in is_lan_address nukes all requests #2897

Closed
devildant opened this Issue Nov 16, 2018 · 20 comments

Comments

4 participants
@devildant

devildant commented Nov 16, 2018

hello,
i use an reverse proxy for octoprint, in 1.3.9 no problem, but with 1.3.10RC i take an internal error

What were you doing?

1 set up a reverse proxy (i use reverse proxy with synology server)
2 call octoprint via the outside of the network by calling the domain name configure in the reverse proxy

What did you expect to happen?

access octoprint

What happened instead?

i get an error 500 :

Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Did the same happen when running OctoPrint in safe mode?

yes

Version of OctoPrint

1.3.10rc2

Operating System running OctoPrint

OctoPi

Printer model & used firmware incl. version

Link to octoprint.log

Traceback (most recent call last):
  File "/home/pi/oprint/local/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/pi/oprint/local/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/pi/oprint/local/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/server/views.py", line 404, in index
    if plugin.will_handle_ui(request):
  File "/home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/forcelogin/__init__.py", line 29, in will_handle_ui
    result = passive_login()
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/server/util/flask.py", line 531, in passive_login
    additional_private=ipCheckTrusted)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/util/net.py", line 59, in is_lan_address
    subnets.add(to_ipnetwork(v6))
  File "/home/pi/oprint/local/lib/python2.7/site-packages/netaddr/ip/sets.py", line 293, in add
    addr = IPNetwork(addr)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/netaddr/ip/__init__.py", line 928, in __init__
    implicit_prefix, flags)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/netaddr/ip/__init__.py", line 823, in parse_ip_network
    raise TypeError('unexpected type %s for addr arg' % type(addr))
TypeError: unexpected type <type 'NoneType'> for addr arg

Link to contents of terminal tab or serial.log

Link to contents of Javascript console in the browser

@GitIssueBot

This comment has been minimized.

Collaborator

GitIssueBot commented Nov 16, 2018

Hi @devildant,

It looks like there is some information missing from your bug report that will be needed in order to solve the problem. Read the Contribution Guidelines which will provide you with a template to fill out here so that your bug report is ready to be investigated (I promise I'll go away then too!).

If you did not intend to report a bug but wanted to request a feature or brain storm about some kind of development, please take special note of the title format to use as described in the Contribution Guidelines.

Please do not abuse the bug tracker as a support forum - that can be found at discourse.octoprint.org. Go there for any kind of issues with network connectivity, webcam functionality, printer detection or any other kind of such support requests or general questions.

Also make sure you are at the right place - this is the bug tracker of the official version of OctoPrint, not the Raspberry Pi image OctoPi nor any unbundled third party OctoPrint plugins or unofficial versions. Make sure too that you have read through the Frequently Asked Questions and searched the existing tickets for your problem - try multiple search terms please.

I'm marking this one now as needing some more information. Please understand that if you do not provide that information within the next two weeks (until 2018-11-30 12:10 UTC) I'll close this ticket so it doesn't clutter the bug tracker. This is nothing personal, so please just be considerate and help the maintainers solve this problem quickly by following the guidelines linked above. Remember, the less time the devs have to spend running after information on tickets, the more time they have to actually solve problems and add awesome new features. Thank you!

Best regards,
~ Your friendly GitIssueBot

PS: I'm just an automated script, not a human being, so don't expect any replies from me :) Your ticket is read by humans too, I'm just not one of them.

@devildant

This comment has been minimized.

devildant commented Nov 16, 2018

@devildant

This comment has been minimized.

devildant commented Nov 16, 2018

i found that : drkjam/netaddr#65

@foosel

This comment has been minimized.

Owner

foosel commented Nov 16, 2018

Can you please provide the full octoprint.log? So far you only posted snippets. Please do not edit it, just upload it in full.

@devildant

This comment has been minimized.

devildant commented Nov 16, 2018

yes of course, I just had to anonymize because my domain name was visible in the log.
octoprint.log

@devildant

This comment has been minimized.

devildant commented Nov 16, 2018

I understood how to solve the problem.
the simple addition of ipCheck: true in the config.yml file fixes the problem

@foosel

This comment has been minimized.

Owner

foosel commented Nov 16, 2018

Thanks. So this is a bit weird because the referenced line numbers in the stack trace don't match the source code in 1.3.10rc2.

I can see what might be happening here though and fix that.

Could you shoot me the output of python -c "import netifaces; print(repr([netifaces.ifaddresses(interface) for interface in netifaces.interfaces()]))" from the python environment OctoPrint is running in (so in your case probably rather ~/oprint/bin/python -c "import netifaces; print(repr([netifaces.ifaddresses(interface) for interface in netifaces.interfaces()]))")? If the returned info contains sensitive data, please shoot me a private mail at gina -at- octoprint.org with it instead of redacting it, the info might be crucial to understand why that error arose).

the simple addition of ipCheck: true in the config.yml file fixes the problem

With that you actually just disabled the ip check (it expects a dictionary here, not a single boolean, so you basically gave it invalid config data which it now ignores). You didn't fix the problem, you hid it, and hiding problems isn't the goal here ;)

foosel added a commit that referenced this issue Nov 16, 2018

@foosel foosel changed the title from reverse proxy with domaine name error with 1.3.10RC to [1.3.10rc2] Exception in is_lan_address nukes all requests Nov 16, 2018

@devildant

This comment has been minimized.

devildant commented Nov 16, 2018

mmm i reinstall octoprint with the 1.3.10RC2 with that :
~/oprint/bin/pip install https://github.com/foosel/OctoPrint/archive/1.3.10rc2.zip
i take same error with different stack :

2018-11-16 12:55:29,090 - octoprint - ERROR - Exception on /api/login [POST]
Traceback (most recent call last):
  File "/home/pi/oprint/local/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/pi/oprint/local/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/pi/oprint/local/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/server/api/__init__.py", line 221, in login
    additional_private=s().get(["server", "ipCheck", "trustedSubnets"]))
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/util/net.py", line 59, in is_lan_address
    subnets.add(to_ipnetwork(v6))
  File "/home/pi/oprint/local/lib/python2.7/site-packages/netaddr/ip/sets.py", line 293, in add
    addr = IPNetwork(addr)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/netaddr/ip/__init__.py", line 928, in __init__
    implicit_prefix, flags)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/netaddr/ip/__init__.py", line 823, in parse_ip_network
    raise TypeError('unexpected type %s for addr arg' % type(addr))
TypeError: unexpected type <type 'NoneType'> for addr arg

the command : python -c "import netifaces; print(repr([netifaces.ifaddresses(interface) for interface in netifaces.interfaces()]))"
return an error :

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named netifaces

for the other command, i will send you the result to your email.

@foosel

This comment has been minimized.

Owner

foosel commented Nov 16, 2018

Weird, that's still a line number that doesn't make sense. The code at that location doesn't contain the cited command. Huh.

the command : python -c "import netifaces; print(repr([netifaces.ifaddresses(interface) for interface in netifaces.interfaces()]))"
return an error

Not surprising, you need to run it in OctoPrint's python environment - that's why I added the second one which takes care of this ;)

for the other command, i will send you the result to your email.

Thank you, got it. Weirdly though I cannot make that data cause an error. In any case, I've made the whole is_lan_address function way more resilient against any kind of errors that arise inside of it, so with rc3 that should no longer happen. Since you are so far the only person who can reliably reproduce this with their setup, once RC3 hits, please upgrade to it, remove your ipCheck adjustment from config.yaml again, restart and check whether it behaves. It should also show you a notification that you are connecting from an external address, if it doesn't there is probably an error logged in octoprint.log in which case please share that too.

@devildant

This comment has been minimized.

devildant commented Nov 16, 2018

Weird, that's still a line number that doesn't make sense. The code at that location doesn't contain the cited command. Huh.

the command : python -c "import netifaces; print(repr([netifaces.ifaddresses(interface) for interface in netifaces.interfaces()]))"
return an error

Not surprising, you need to run it in OctoPrint's python environment - that's why I added the second one which takes care of this ;)

for the other command, i will send you the result to your email.

Thank you, got it. Weirdly though I cannot make that data cause an error. In any case, I've made the whole is_lan_address function way more resilient against any kind of errors that arise inside of it, so with rc3 that should no longer happen. Since you are so far the only person who can reliably reproduce this with their setup, once RC3 hits, please upgrade to it, remove your ipCheck adjustment from config.yaml again, restart and check whether it behaves. It should also show you a notification that you are connecting from an external address, if it doesn't there is probably an error logged in octoprint.log in which case please share that too.

no problem, as soon as the RC3 will be available, I will test, and I will make a return on this post.
I encounter another problem with the return of the plugins. When I go through the reverse proxy, I have the call network, but at the level of the view, they does not updates, if RC3 I still have this problem, I will create another bug report

@foosel

This comment has been minimized.

Owner

foosel commented Nov 16, 2018

No, please create it now ;) If there's even the chance of an issue I need to look into that now, I'd rather not have to keep putting out RCs solved issue by solved issue, it's a tremendous amount of work each time, so the goal is to keep the number of RCs as low as possible and that means fixing ALL issues that are observed per RC if possible.

@devildant

This comment has been minimized.

devildant commented Nov 16, 2018

ha ok, I'm doing it right now :)

@devildant

This comment has been minimized.

devildant commented Nov 16, 2018

new issue create.

small precision for the current bug, I deleted cookies, I have no more error 500 but I can not pass the login page, the error cited above appears with each temptation to login with my login / password

@foosel

This comment has been minimized.

Owner

foosel commented Nov 20, 2018

@devildant I was just wondering, since you updated to staging/maintenance anyhow, could you check whether this issue is resolved for you?

@devildant

This comment has been minimized.

devildant commented Nov 20, 2018

@foosel oops, i forgot to test this case: p i do it right after my current print

@devildant

This comment has been minimized.

devildant commented Nov 20, 2018

@foosel , i removed ipCheck config, i get the staging/maintenance, and, i tried to login with my phone (3g), no error.
This seems good :)

thank you for your work

@foosel

This comment has been minimized.

Owner

foosel commented Nov 20, 2018

Perfect, marking this as solved then, will close it when RC3 is out.

@louispires

This comment has been minimized.

louispires commented Nov 23, 2018

@devildant what is the workaround for this issue to get it working on RC2?

Should I just add the ipCheck: true to the config?

@foosel

This comment has been minimized.

Owner

foosel commented Nov 23, 2018

Rather set server.ipCheck.enabled to false:

server:
  ipCheck:
    enabled: false
@foosel

This comment has been minimized.

Owner

foosel commented Nov 28, 2018

1.3.10rc3 was just released.

@foosel foosel closed this Nov 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment