Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

bugfix: fix async certificate decoding#1085

Merged
clundin25 merged 1 commit intogoogleapis:mainfrom
clundin25:main
Jul 22, 2022
Merged

bugfix: fix async certificate decoding#1085
clundin25 merged 1 commit intogoogleapis:mainfrom
clundin25:main

Conversation

@clundin25
Copy link
Copy Markdown
Contributor

@clundin25 clundin25 commented Jul 20, 2022

The async _cert_fetch implementation was not properly decoding
certificates into a utf-8 string. This updates the code and tests to
decode the certificates into strings.

Without this fix, the code will raise a ValueError exception, because the data type passed to json.dumps is not expected.

This resolves #1050.

@clundin25 clundin25 requested a review from a team July 20, 2022 00:43
data = await response.data.read()

return json.loads(json.dumps(data))
return json.loads(data.decode("utf-8"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works )

and a question to @arithmetic1728: I wonder if there is a way we can decode all the responses at the time we get them... so we don't have to remember this next time

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be achieved by adding a new decoded_data property in parallel to the data property in the _Response class

@property
def data(self):
return self._response.content

@clundin25 clundin25 force-pushed the main branch 3 times, most recently from 37d2843 to ea58c02 Compare July 21, 2022 16:04
The async `_cert_fetch` implementation was not properly decoding
certificates into a utf-8 string. This updates the code and tests to
decode the certificates into strings.

This resolves googleapis#1050.
@clundin25 clundin25 added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 22, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 22, 2022
@clundin25 clundin25 merged commit 741c6c6 into googleapis:main Jul 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Async _fetch_certs does not decode certs - TypeError Object of type bytes is not JSON serializable

4 participants