Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

sentry_sdk/integrations/pymongo.py:151: BytesWarning: str() on a bytes instance

Đang mở Phù hợp với người mới
#4,782 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
74/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
mongodb, python
Lĩnh vực
backend, databases

Hướng nghiên cứu

Bắt đầu tại sentry_sdk/integrations/pymongo.py:151, trong điểm vào started, và kiểm tra việc chuyển đổi lsid khi chạy Python với BytesWarning được bật nếu có thể. Được coi là hoàn tất khi tích hợp PyMongo không còn phát BytesWarning cho đường dẫn này; hãy thêm hoặc cập nhật phần kiểm thử hồi quy liên quan nếu repository cung cấp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

good first issue Improvement Integration: MongoDB Python Waiting for: Product Owner
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

Ngôn ngữ chính
Python
Star
2.2k
Fork
672
Merge trung bình
22 giờ 54 phút
Pull request đã merge (30 ngày)
235

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của getsentry/sentry-python

Tất cả issue của getsentry/sentry-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.