-
Notifications
You must be signed in to change notification settings - Fork 469
Fix UnicodeDecodeError in aioredis integration #3089
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
Conversation
Escape non-unicode bytes when decoding aioredis args. This prevents the `UnicodeDecodeError` while still offering some semblance of a human-readable string for tracing.
be49e43 to
c0e13e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for catching the issue and submitting this fix @jalaziz!
Elsewhere in the code, we replace errors with the replacement character �. Can we do the same here?
And, it would be great to include tests for the issue you found with how channels-redis calls the patched functions. It can be synthetic test where we check args. Or pulling out the decoding code and adding unit tests for such a function.
@majorgreys I had thought about that, but that's lossy. I figured capturing the actual bytes may be more useful when debugging using traces. HOWEVER, for the pipeline commands, the args are simply passed to Another option would be to use
Will do, was looking at adding tests yesterday but it was 5am and I wanted to get the PR out first to get feedback 😄 |
I agree that having the unicode input string escaped with a backslash has a benefit when looking at trace data. For the purposes of your fix here, your choice is fine!
That does seem like an option but we'd then have a utility function in the redis integration that must support the arguments other integrations need to handle. Still, the decoding of args could be handled instead by not calling dd-trace-py/ddtrace/contrib/redis/util.py Line 44 in 425964a
ensure_text as we do elsewhere.
This discussion over whether the change for this fix should happen in the aioredis integration patching code or the utility function it uses from the redis integration is one I'd like to have @Kyle-Verhoog and @brettlangdon's thoughts on as well. |
Centralizing the fix and not just fixing it for |
|
Added tests. Happy to centralize the handling for this, but where should it live and should it use |
|
@jalaziz Thanks for adding the tests! You'd want to use |
Codecov Report
@@ Coverage Diff @@
## master #3089 +/- ##
=======================================
Coverage 84.55% 84.55%
=======================================
Files 638 638
Lines 46289 46314 +25
=======================================
+ Hits 39138 39163 +25
Misses 7151 7151
Continue to review full report at Codecov.
|
@majorgreys Turns out |
57a7200 to
bf3d1cc
Compare
brettlangdon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comments, otherwise lgtm
|
We do need to add a changelog entry: This would be a "fixes:" entry. |
cb1a6c5 to
64cd8a3
Compare
Done! |
|
Seems like random integration checks are failing, but not quite sure why. |
|
@Mergifyio backport 0.57 |
🟠 Waiting for conditions to match
|
|
@brettlangdon Anything else needed to merge this? Should I squash? |
|
@jalaziz we need one more approving review. No worries on squashing, we squash merge all PRs. |
✅ Backports have been created
|
|
@jalaziz this is now merged / backported into the (I'll probably do a bug fix release Monday no matter what, bug fix releases are cheap we won't hold this fix for long) |
Thanks! I saw the other PRs (subscribed to yours). Would indeed be good to get them all in. |
Commit Message
Fix UnicodeDecodeError in aioredis integration
Escape non-unicode bytes when decoding aioredis args. This prevents the
UnicodeDecodeErrorwhile still offering some semblance of ahuman-readable string for tracing.
fixes #3088
Checklist