Skip to content

Commit

Permalink
Deepcopy only headers in validator (#1710)
Browse files Browse the repository at this point in the history
Fixes the failing pipeline.

I don't understand the underlying issue completely, but It's related to
[this
code](encode/starlette@0.27.0...0.28.0#diff-87bccafe494bc79680d9d8f57ea797733354b076aa411c0e2bd63f5b4039f71fR51-R54)
added in starlette 0.28. This makes the scope unpicklable in some cases,
leading to an error when trying to deepcopy it.

I replaced the deepcopy of the whole scope with just a deepcopy of the
headers, since this is the only part we're chaning.
  • Loading branch information
RobbeSneyders committed Jun 11, 2023
1 parent fcd4e66 commit 55f3c59
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion connexion/validators/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def _insert_body(self, receive: Receive, *, body: t.Any, scope: Scope) -> Receiv
bytes_body = json.dumps(body).encode(self._encoding)

# Update the content-length header
new_scope = copy.deepcopy(scope)
new_scope = scope.copy()
new_scope["headers"] = copy.deepcopy(scope["headers"])
headers = MutableHeaders(scope=new_scope)
headers["content-length"] = str(len(bytes_body))

Expand Down

0 comments on commit 55f3c59

Please sign in to comment.