python-amazon-sp-api: zlib.error: Error -3 while decompressing data: incorrect header check

Describe the bug Since 21/06/23 01:00 AM UTC, we cannot get feed result documents of json listings feeds.

Traceback:

return service.get_feed_result_document(document_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/mpinfestor/lib/python3.11/site-packages/sp_api/base/helpers.py", line 20, in wrapper
    return function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/mpinfestor/lib/python3.11/site-packages/sp_api/api/feeds/feeds.py", line 233, in get_feed_result_document
    return zlib.decompress(bytearray(content), 15 + 32).decode(encoding)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
zlib.error: Error -3 while decompressing data: incorrect header check
Failed: NonZeroResultCode: [ssh-exec] Result code: 1

To Reproduce

Steps to reproduce the behavior:

  • Create and submit a json listings feed
  • Get the feed id
  • Call the Feeds.get_feed_result_document(feed_id) operation

Desktop (please complete the following information):

  • OS: Linux 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 20 (12 by maintainers)

Most upvoted comments

Hello, we have the same error. Looks like an amazon error to me

Something like this can be temporary used. NOTE - this is temporary, until we get proper communication. Also you can check if file is really GZIP to have more granular control.

class CustomReport(Reports):

	@sp_endpoint('/reports/2021-06-30/documents/{}', method='GET')
	def get_report_document(self, reportDocumentId, download: bool = False, file=None,
							character_code: str = 'iso-8859-1', **kwargs) -> ApiResponse:
		res = self._request(fill_query_params(kwargs.pop('path'), reportDocumentId), add_marketplace=False)
		if download or file or ('decrypt' in kwargs and kwargs['decrypt']):
			document = requests.get(res.payload.get('url')).content
			if 'compressionAlgorithm' in res.payload:
				# FIXME: this is temporary fix for issue with compression from Amazon.
				try:
					document = zlib.decompress(bytearray(document), 15 + 32)
				except Exception as e:
					document = document

			if character_code:
				document = document.decode(character_code)
			if download:
				res.payload.update({
					'document': document
				})
			if file:
				self._handle_file(file, document, character_code)
		return res

hi! I created issue on SP API documentation report. Please add comments there so we get attention from Amazon.

good idea I’ve also created a case on Developper Support

hi! I created issue on SP API documentation report. Please add comments there so we get attention from Amazon.

We also start facing the same issue using Amazon Selling Partner Reports API.

This error is raised when we try to download already successfully completed report and call get_report_document(...).

from sp_api.api import Reports

Reports(marketplace=marketplace, credentials=credentials).get_report_document(reportDocumentId=document_id, download=True, file=path, decrypt=True)


error: Error -3 while decompressing data: incorrect header check
Traceback (most recent call last):
    .....
    Reports(marketplace=marketplace, credentials=credentials).get_report_document(reportDocumentId=document_id, download=True, file=path, decrypt=True)
  File "/usr/local/lib/python3.8/dist-packages/sp_api/base/helpers.py", line 19, in wrapper
    return function(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/sp_api/api/reports/reports.py", line 369, in get_report_document
    document = zlib.decompress(bytearray(document), 15 + 32)
zlib.error: Error -3 while decompressing data: incorrect header check

Issue is reproducible for 2 types of DAILY reports:

  1. ReportType.GET_VENDOR_INVENTORY_REPORT
  2. ReportType.GET_VENDOR_SALES_REPORT

Hi, downgrading to 0.18.0 version of the SDK is resolving the issue.

Doesn’t work for us. We were on 0.18.0. already - having this issue though.