fix(charts): skip empty string filter values to prevent invalid datetime format#1417
Open
sentry[bot] wants to merge 1 commit into
Open
fix(charts): skip empty string filter values to prevent invalid datetime format#1417sentry[bot] wants to merge 1 commit into
sentry[bot] wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inapply_dashboard_filtersandapply_chart_filtersdid not adequately guard against empty strings, leading to SQL queries likeWHERE date = '', which PostgreSQL rejects as an invalid date format.Solution:
Implemented guards in
ddpui/core/charts/charts_service.pywithin theapply_dashboard_filtersandapply_chart_filtersfunctions. These guards now check forNoneor 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 tois_nullandis_not_nulloperators, which legitimately operate without a value, ensuring they are not inadvertently skipped by the new guard.Fixes DALGO-BACKEND-2J7