You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some cases (in my case when psycopg3 connection pooling is enabled in a Django project) the SQL statement may be an empty string, which causes a traceback in the sqlcommenter.
[2025-02-28 04:37:32,454] [__init__] [ERROR]: "Exception while generating sql comment: string index out of range"
Traceback (most recent call last):
File "/Users/selcuk/src/testapp/.venv/lib/python3.12/site-packages/opentelemetry/instrumentation/dbapi/__init__.py", line 505, in _update_args_with_added_sql_comment
statement = _add_sql_comment(args_list[0], **commenter_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/selcuk/src/testapp/.venv/lib/python3.12/site-packages/opentelemetry/instrumentation/sqlcommenter_utils.py", line 26, in _add_sql_comment
if sql[-1] == ";":
~~~^^^^
IndexError: string index out of range
Additional context
No response
Would you like to implement a fix?
Yes
The text was updated successfully, but these errors were encountered:
Describe your environment
OS: Debian, macOS
Python version: Python 3.12
Package version: 0.51b2
Django version: 5.1.6
What happened?
In some cases (in my case when
psycopg3
connection pooling is enabled in a Django project) the SQL statement may be an empty string, which causes a traceback in thesqlcommenter
.Steps to Reproduce
opentelemetry-instrumentation-django
,opentelemetry-instrumentation-dbapi
,opentelemetry-instrumentation-psycopg
)Expected Result
No traceback.
Actual Result
Getting a traceback:
Additional context
No response
Would you like to implement a fix?
Yes
The text was updated successfully, but these errors were encountered: