question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Header Parsing Error

See original GitHub issue

Operation Azure BlockBlobService save operation

Expected Result Operation completed with no errors

Actual Result Sometimes a HeaderParsingError is raised

Versions Running in docker container image python:3.6.3-jessie

pip freeze
azure==2.0.0
azure-storage==0.34.3
azure-storage-blob==1.0.0

Relevant Information

Running the following code:

from azure.storage.blob import BlockBlobService
service = BlockBlobService(account_name, account_key)
...
self.service.create_blob_from_bytes(self.container_name,
    blob_name=ref_id, blob=compressed_data, metadata=metadata)

Sometimes produces this error:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", 
        line 398, in _make_request
    assert_header_parsing(httplib_response.msg)
File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/util/response.py", 
        line 66, in assert_header_parsing
    raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
    requests.packages.urllib3.exceptions.HeaderParsingError: [
        StartBoundaryNotFoundDefect(), 
        MultipartInvariantViolationDefect()], unparsed data: ''

Relevant header info:

Receiving Response: Server-Timestamp=Thu, 08 Feb 2018 20:43:09 GMT, 
Server-Request-ID=*guid*, HTTP Status Code=201, Message=Created, 
Headers={
    'x-ms-blob-type': 'BlockBlob',
    'x-ms-lease-id': None, 
    'If-Modified-Since': None, 
    'If-Unmodified-Since': None, 
    'If-Match': None, 
    'If-None-Match': None, 
    'x-ms-meta-encoding': 'application/json', 
    'x-ms-meta-compression': 'gzip', 
    'Content-Length': '547', 
    'x-ms-version': '2017-04-17', 
    'User-Agent': 'Azure-Storage/1.0.0-1.0.0 
        (Python CPython 3.6.3; Linux 4.9.60-linuxkit-aufs)', 
    'x-ms-client-request-id': '*guid*', 
    'x-ms-date': 'Thu, 08 Feb 2018 20:43:09 GMT', 
    'Authorization': 'SharedKey myusername:mykey'}

For now, I have a try/except block around the creation catching HeaderParsingError to ignore it. Is this safe to do? Is there a way to prevent the error at all?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
zezha-msftcommented, Feb 14, 2018

Hi @dagrooms52, I really apologize for the confusion and inconvenience. The azure mega-package is installing the old deprecated azure-storage, so I’ve created a PR to fix that. Thanks for raising the issue here.

As for the table service, you should definitely use azure-cosmosdb-table. As for the import error ImportError: cannot import name '_to_int', I think that it is because azure-cosmosdb-table is depending on an older version of azure-storage-common, and when you installed azure-cosmosdb-table it overwrote the new/correct azure-storage-common (1.1.0). I’ve created an issue on their repo to fix this problem.

Thanks to your issue I realized that it was not a very nice experience installing/using the storage packages along with other azure packages. I’ll be more mindful in the future. Thank you!

Please let me know if you are still encountering problems.

0reactions
dagrooms52commented, Feb 13, 2018

I’m now getting an error when importing both the TableService and the BlobService in the same file (I don’t actually do this, I import both of the wrappers I’ve made for these services, which in turn import the services, but I’m not doing import *).

File "myapp/api/wsgi.py", line 2, in <module>
  from myapp.api import application
File "/myapp/myapp/api/application.py", line 9, in <module>
  from myapp.api import views
File "/myapp/myapp/api/views.py", line 6, in <module>
  from myapp.api import view_wrappers
File "/myapp/myapp/api/view_wrappers.py", line 4, in <module>
  from myapp.implementation import backend
File "/myapp/myapp/implementation/backend.py", line 19, in <module>
  from myapp.implementation.utilities.auditing.storage_accounts import blob_storage, table_storage
File "/myapp/myapp/implementation/utilities/auditing/storage_accounts.py", line 3, in <module>
  from myapp.implementation.utilities.azure_storage.blob_storage import BlockBlobUtility
File "/myapp/myapp/implementation/utilities/azure_storage/blob_storage.py", line 5, in <module>
  from azure.storage.blob import BlockBlobService
File "/usr/local/lib/python3.6/site-packages/azure/storage/blob/__init__.py", line 6, in <module>
  from .appendblobservice import AppendBlobService
File "/usr/local/lib/python3.6/site-packages/azure/storage/blob/appendblobservice.py", line 30, in <module>
  from ._deserialization import (
File "/usr/local/lib/python3.6/site-packages/azure/storage/blob/_deserialization.py", line 18, in <module>
  from azure.storage.common._deserialization import (
ImportError: cannot import name '_to_int'

It appears that the name _to_int is imported into the scope by both of these modules, and they are stepping on each other.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve parse error when HTTP content-type header is ...
In order to resolve this issue, one can use one of the following methods to set the HTTP content-type header with correct value:...
Read more >
Tomcat 7.0.43 "INFO: Error parsing HTTP request header"
If there are too many cookies cached, it breaks the server (the size of a request header is too big ...
Read more >
Tomcat Resolve "Error parsing HTTP request header" - FreeKB
"Error parsing HTTP request header" appears in catalina.log. 26-Jul-2022 01:13:52.454 INFO [tomcat-http--27] org.apache.coyote.http11.
Read more >
Tomcat 8 HTTP header parsing error - Server Fault
This error normaly is caused when you try to do a https request to a port that only accept http. I'm not sure...
Read more >
Parse Error: Header overflow · Issue #8656 - GitHub
Since Version 7 of Postman I am experiencing an issue with header size from Some Huawei cloud service APIs. The error manifests itself...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found