sentry_sdk/integrations/pymongo.py:151: BytesWarning: str() on a bytes instance
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
Research direction
Start at sentry_sdk/integrations/pymongo.py:151, in the started entry point, and inspect the conversion of lsid while running Python with BytesWarning enabled if possible. Done means the PyMongo integration no longer emits BytesWarning for this path; add or update the relevant regression coverage if the repository provides it.
Written by the indexing model from the issue text.
Description
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.37.0
Steps to Reproduce
From Discord:
If run Python with the BytesWarning mode (using the -b flag), i see this messages in my logs. This probably highlights a bug. If "b'...........'" string should be there, it should probably be replaced with repr() for better readability. Otherwise, we should use decode here.
https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/pymongo.py#L151
Currently, I cannot provide a small code sample that reproduces this warning, but I can provide a part of stack trace that I generated.
<.....>
<.....>
File "<***>/lib/python3.9/site-packages/pymongo/database.py", line 1005, in collection_names
for result in self.list_collections(session=session, nameOnly=True, **kws)
File "<***>/lib/python3.9/site-packages/pymongo/database.py", line 943, in list_collections
return self.__client._retryable_read(_cmd, read_pref, session)
File "<***>/lib/python3.9/site-packages/pymongo/mongo_client.py", line 1617, in _retryable_read
return func(session, server, sock_info, secondary_ok)
File "<***>/lib/python3.9/site-packages/pymongo/database.py", line 939, in _cmd
return self._list_collections(
File "<***>/lib/python3.9/site-packages/pymongo/database.py", line 880, in _list_collections
cursor = self._command(
File "<***>/lib/python3.9/site-packages/pymongo/database.py", line 703, in _command
return sock_info.command(
File "<***>/lib/python3.9/site-packages/pymongo/pool.py", line 740, in command
return command(
File "<***>/lib/python3.9/site-packages/pymongo/network.py", line 155, in command
listeners.publish_command_start(
File "<***>/lib/python3.9/site-packages/pymongo/monitoring.py", line 1412, in publish_command_start
subscriber.started(event)
File "<***>/lib/python3.9/site-packages/sentry_sdk/integrations/pymongo.py", line 151, in started
data["operation_ids"]["session"] = str(lsid)
My versions:
Python 3.9.21
pymongo==3.13.0
sentry-sdk==2.37.0
Expected Result
No BytesWarning
Actual Result
BytesWarning
- Dominant language
- Python
- Stars
- 2.2k
- Forks
- 672
- Avg merge
- 23h 14m
- Merged PRs (30d)
- 218
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from getsentry/sentry-python
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
getsentry/sentry-python#7543 · 2 comments · 1 assignee ·
-
Python
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
getsentry/sentry-python#6992 · 1 comment ·
-
Improvement Python
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
getsentry/sentry-python#6970 · 1 comment ·
-
Bug Python
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
getsentry/sentry-python#6504 · 1 comment ·
-
Improvement Python Spans
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
getsentry/sentry-python#5833 · 1 comment ·
All issues in getsentry/sentry-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main Openarea: ci bug perceived difficulty: 3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/clickhouse-connect#1057 ·