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

[1.4.0rc1] Unset optional header fields in upload parts can cause exceptions #3349

Closed
foosel opened this issue Nov 26, 2019 · 3 comments

Comments

@foosel
Copy link
Owner

@foosel foosel commented Nov 26, 2019

Problem

If a part's filename, content type or such are unset on the upload, the corresponding field will stay at None. Trying to put that into the rewritten request body will cause an exception due to incompatible operands:

2019-11-25 17:09:34,089 - tornado.application - ERROR - Uncaught exception
Traceback (most recent call last):
  File "/home/pi/oprint/local/lib/python2.7/site-packages/tornado/http1connection.py", line 584, in _read_fixed_body
    ret = delegate.data_received(body)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/tornado/httpserver.py", line 311, in data_received
    return self.delegate.data_received(chunk)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/tornado/routing.py", line 248, in data_received
    return self.delegate.data_received(chunk)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/tornado/web.py", line 2087, in data_received
    return self.handler.data_received(data)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/server/util/tornado.py", line 271, in data_received
    self._process_multipart_data(data)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/server/util/tornado.py", line 316, in _process_multipart_data
    self._on_request_body_finish()
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/server/util/tornado.py", line 468, in _on_request_body_finish
    self._new_body += octoprint.util.to_bytes(p) + b'\r\n'
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

See also #3347 (comment) and #3347 (comment)

Solution

Do not try to write None values into the new body in the first place

@gferon

This comment has been minimized.

Copy link

@gferon gferon commented Nov 26, 2019

I had a smell that this would be about the HTTP headers. Thanks for fixing it so quickly!

@devildant

This comment has been minimized.

Copy link
Contributor

@devildant devildant commented Nov 26, 2019

thx @foosel
sorry i did not have time to answer before (i'm at work :))

@foosel

This comment has been minimized.

Copy link
Owner Author

@foosel foosel commented Dec 2, 2019

1.4.0rc2 is out.

@foosel foosel closed this Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.