Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update logging to coerce ASCII-8BIT into UTF-8. #1076

Merged
merged 1 commit into from
Jun 21, 2022
Merged

Conversation

dcr-stripe
Copy link
Contributor

r? @stripe/server-api-libraries-admins

Summary

Updates our logging utilities to transform any string encoded as ASCII-8bit (raw binary) to UTF-8 when logging out.

The strings returned from the server are in ASCII-8bit until the JSON marshaller transforms them to UTF-8. Unfortunately we have logging statements which pass the raw content sent back from the server. puts fails to interpret these as 8bit because they're actually utf-8 characters.

So, we force any binary string to actually be encoded as UTF-8 for the purposes of debug logging.

Alternatives:

  1. We could do a more localized fix here just for the body, but my worry is this will then become a game of whack-a-mole and finding all of the logging calls which pass the raw body.
  2. We could potentially immediately encode the response received from the server, but I'm worried about the downstream implications here (eg. if anyone is using the requesting infra). This change is limited to debug logging infra.

Motivation

Fix #1059

@dcr-stripe dcr-stripe requested review from a team and kamil-stripe and removed request for a team June 21, 2022 20:22
@dcr-stripe dcr-stripe merged commit 9092e9d into master Jun 21, 2022
pakrym-stripe added a commit that referenced this pull request Jun 30, 2022
* fix: Update logging to coerce ASCII-8BIT into UTF-8. (#1076)

* Add release/* and feature/* to PR CI triggers (#1080)

* Add next-major-release to PR CI triggers

* Update branch names

* Rename release to sdk-release in CI triggers

* API Updates (#1084)

* Bump version to 6.5.0

* Set version to 6.5.0 to simplify merge

* Reset version to 6.4.0

Co-authored-by: Dominic Charley-Roy <[email protected]>
Co-authored-by: Kamil Pajdzik <[email protected]>
Co-authored-by: Dominic Charley-Roy <[email protected]>
@remi-stripe remi-stripe deleted the dcr-fix branch September 28, 2023 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Encoding::UndefinedConversionError with STRIPE_LOG_LEVEL=debug
2 participants