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

patch occasional UnicodeEncodeError that occurs with outgoing webhooks #3832

Merged
merged 4 commits into from
Feb 2, 2024

Conversation

joeyorlando
Copy link
Contributor

Which issue(s) this PR fixes

Closes #3831

Checklist

  • Unit, integration, and e2e (if applicable) tests updated
  • Documentation added (or pr:no public docs PR label added if not required)
  • CHANGELOG.md updated (or pr:no changelog PR label added if not required)

that occurs with outgoing webhooks
@joeyorlando joeyorlando added the pr:no public docs Added to a PR that does not require public documentation updates label Feb 2, 2024
@joeyorlando joeyorlando requested a review from a team February 2, 2024 20:27
ALERT_GROUP_PUBLIC_PRIMARY_KEY = "IXJ47FKMYYJ5U"


@httpretty.activate(verbose=True, allow_net_connect=False)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the exception I was trying to fix, and fully test, here happens rather deep inside the requests package (logs). Rather than trying to figure out what to properly mock there I decided to try out httpretty which according to their docs:

It can be a bit of a hassle to use something like mock.Mock to stub the requests, this can work well for low-level unit tests but when writing functional or integration tests we should be able to allow the http calls to go through the TCP socket module.

HTTPretty monkey patches Python’s socket core module with a fake version of the module.

Because HTTPretty implements a fake the modules socket and ssl you can use write tests to code against any HTTP library that use those modules.

in other words, we don't have to patch requests at all (note: I'm patching requests but w/ the wraps kwarg which basically sets a "spy" on the package and doesn't mock its actual implementation (docs))

Copy link
Contributor

@matiasb matiasb left a comment

Choose a reason for hiding this comment

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

LGTM

@joeyorlando joeyorlando enabled auto-merge February 2, 2024 21:00
@joeyorlando joeyorlando added this pull request to the merge queue Feb 2, 2024
Merged via the queue into dev with commit e477394 Feb 2, 2024
21 checks passed
@joeyorlando joeyorlando deleted the jorlando/fix-webhook-unicode-encode-error branch February 2, 2024 21:17
iskhakov pushed a commit that referenced this pull request Feb 20, 2024
…oks (#3832)

# Which issue(s) this PR fixes

Closes #3831

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:no public docs Added to a PR that does not require public documentation updates
Projects
None yet
2 participants