[Bug]: Chunked request from request libraly

Open
#554 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
api

Research direction

Start with the requests integration entry points RequestsOpenAPIRequest, RequestsOpenAPIResponse, and unmarshal_response, then reproduce the failure using the chunk_generator example. Trace how the request body is inspected during unmarshaling. Done means a chunked request no longer triggers the assertion and the chunked body is checked as far as supported.

Written by the indexing model from the issue text.

Description

kind/bug kind/bug/confirmed
Actual Behavior

When it shout check response where request data was chunked it fails.

    @property
    def body(self) -> Optional[str]:
        if self.request.body is None:
            return None
        if isinstance(self.request.body, bytes):
            return self.request.body.decode("utf-8")
>       assert isinstance(self.request.body, str)
E       AssertionError
Expected Behavior

Check everithing which can, ideally chunked body itself.

Steps to Reproduce
    @staticmethod
    def chunk_generator(data):
        for block in raw:
            yield block
request = Request(method, url, headers=headers, data=chunk_generator(data), **kwargs)
response = session.send(session.prepare_request(request))  
openapi_request = RequestsOpenAPIRequest(request)
openapi_response = RequestsOpenAPIResponse(response)
unmarshal_response(openapi_request, openapi_response, self.spec)
OpenAPI Core Version

0.17.1

OpenAPI Core Integration

requests

Affected Area(s)

unmarshaling

References

No response

Anything else we need to know?

No response

Would you like to implement a fix?

None

Dominant language
Python
Stars
368
Forks
140
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-openapi/openapi-core

All issues in python-openapi/openapi-core

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.