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
{{ message }}
Repository navigation
clickhouse-driver integration eats inserted data when generator is used #4657
In a Django project using clickhouse-driver (0.2.9) to interact with an external database I recently upgraded sentry sdk. Inserting data into clickhouse stopped working afterward. The reason was that we are using a generator as a source of data for the INSERT query and the sentry clickhouse-driver integration consumes the generator before it is passed to the clickhouse-driver. Thus an INSERT is sent to clickhouse with empty data.
This is a barebones example where using a generator to pass the data results in no data being written to the database.
When I replaced the generator with a generator which would throw an Exception, I got the following traceback:
File "/opt/virtualenvs/celus/lib/python3.12/site-packages/clickhouse_driver/client.py", line 376, in execute
rv = self.process_insert_query(
File "/opt/virtualenvs/celus/lib/python3.12/site-packages/clickhouse_driver/client.py", line 607, in process_insert_query
rv = self.send_data(sample_block, data,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/virtualenvs/celus/lib/python3.12/site-packages/sentry_sdk/integrations/clickhouse_driver.py", line 142, in _inner_send_data
db_params.extend(data)
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/virtualenvs/celus/lib/python3.12/site-packages/hcube/backends/clickhouse/backend.py", line 64, in ff
raise ValueError('sh*t, someone ate my data')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Which shows the point where the generator gets consumed.
I was able to reproduce the behavior you observed, and it indeed appears to be a bug, which occurs when send_default_pii=True is set in your sentry_sdk.init call. As a temporary workaround while you wait for a fix, you can set send_default_pii=False in sentry_sdk.init (or you can remove the configuration, as the default is False when the parameter is missing).
Activity
linear commentedon Aug 3, 2025
PY-1795 clickhouse-driver integration eats inserted data when generator is used
szokeasaurusrex commentedon Aug 4, 2025
Hi @beda42, thank you for reporting this issue.
I was able to reproduce the behavior you observed, and it indeed appears to be a bug, which occurs when
send_default_pii=Trueis set in yoursentry_sdk.initcall. As a temporary workaround while you wait for a fix, you can setsend_default_pii=Falseinsentry_sdk.init(or you can remove the configuration, as the default isFalsewhen the parameter is missing).fix(clickhouse): Don't eat the generator data
fix(clickhouse): Don't eat the generator data
fix(clickhouse): Don't eat the generator data
fix(clickhouse): Don't eat the generator data
fix(clickhouse): Don't eat the generator data (#4669)
fix(clickhouse): Don't eat the generator data (#4669)