0

Having a strange issue while trying to use aiohttp/asyncio with Artifactory REST API.

The strange thing is that the below code works perfectly for 'url_2' but permanently fails with aiohttp.client_exceptions.ClientPayloadError: Response payload is not completed for 'url_1'. As you can see, there is absolutely no difference between these URLs.

import aiohttp
import asyncio

user_name = 'username'
user_password = 'password'

url_1 = 'https://someorg.jfrog.io/someorg/api/storage/repo/folder-xxx' # fails
url_2 = 'https://someorg.jfrog.io/someorg/api/storage/repo/folder-yyy' # works

async def fetch(url, user_name, user_password):
    async with aiohttp.ClientSession(auth=aiohttp.BasicAuth(user_name, user_password)) as session:
        remote_resp = await session.request("GET", url)
        return await remote_resp.json()

r = asyncio.run(fetch(url_1, user_name, user_password))
print(r)

I am thinking that this has something to do with chunks, as they state it here: https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientPayloadError

class aiohttp.ClientPayloadError

This exception can only be raised while reading the response payload if one of these errors occurs:

  • invalid compression
  • malformed chunked encoding
  • not enough data that satisfy Content-Length HTTP header.

Literally stuck and have no ideas :( FYI: duplicated issue to aio-lib at https://github.com/aio-libs/aiohttp/issues/2076

Could anyone point the direction to at least debug and define the root cause?

Community
  • 1
  • 1
zumby
  • 69
  • 1
  • 4
  • Provide minimal reproducible example (Link)[https://stackoverflow.com/help/minimal-reproducible-example] because your code doesn't raise `ClientPayloadError`, also check if the response returned by the server itlsef is correct or not? – Gaurav Dhiman Jan 06 '20 at 07:09
  • @GauravDhiman I'd be glad to, but I cannot do that, as this is a private Artifacrory account. This exact code returns the error only and only when trying to access some 'special' links. I've seen 2 or 3 of them, but they are really the same as the 'normal' ones. – zumby Jan 06 '20 at 07:13

0 Answers0