Skip to content

fix(charts): skip empty string filter values to prevent invalid datetime format#1417

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/charts-empty-filter-value
Open

fix(charts): skip empty string filter values to prevent invalid datetime format#1417
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/charts-empty-filter-value

Conversation

@sentry

@sentry sentry Bot commented Jun 23, 2026

Copy link
Copy Markdown

This PR addresses issue DALGO-BACKEND-2J7, where a DataError: (psycopg2.errors.InvalidDatetimeFormat) invalid input syntax for type date: "" occurred during chart data preview.

Root Cause:
The error was caused by empty string values ("") being passed as filter values for date columns. Specifically, when a user cleared a date filter, the frontend would send {"column": "date", "operator": "equals", "value": "", "data_type": "date"}. The backend's filter application logic in apply_dashboard_filters and apply_chart_filters did not adequately guard against empty strings, leading to SQL queries like WHERE date = '', which PostgreSQL rejects as an invalid date format.

Solution:
Implemented guards in ddpui/core/charts/charts_service.py within the apply_dashboard_filters and apply_chart_filters functions. These guards now check for None or empty/blank string values (value is None or (isinstance(value, str) and not value.strip())) and skip applying such filters to the SQL query. Special consideration was given to is_null and is_not_null operators, which legitimately operate without a value, ensuring they are not inadvertently skipped by the new guard.

Fixes DALGO-BACKEND-2J7

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.26%. Comparing base (11a5843) to head (35f94fd).

Files with missing lines Patch % Lines
ddpui/core/charts/charts_service.py 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1417      +/-   ##
==========================================
- Coverage   60.26%   60.26%   -0.01%     
==========================================
  Files         146      146              
  Lines       17222    17227       +5     
==========================================
+ Hits        10378    10381       +3     
- Misses       6844     6846       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants