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

foosel opened this issue Nov 26, 2019 · 3 comments


Copy link

@foosel foosel commented Nov 26, 2019


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/", line 584, in _read_fixed_body
    ret = delegate.data_received(body)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/tornado/", line 311, in data_received
    return self.delegate.data_received(chunk)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/tornado/", line 248, in data_received
    return self.delegate.data_received(chunk)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/tornado/", line 2087, in data_received
    return self.handler.data_received(data)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/server/util/", line 271, in data_received
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/server/util/", line 316, in _process_multipart_data
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/server/util/", 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)


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


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!


This comment has been minimized.

Copy link

@devildant devildant commented Nov 26, 2019

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


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
None yet
3 participants
You can’t perform that action at this time.