ISSUE DESCRIPTION [Filters] Backend do not accept conditional groups Describe the issue…
- User
ISSUE DESCRIPTION
[Filters] Backend do not accept conditional groups
Describe the issue
HTTP 400 is returned at a simple conditional group filter query.
Reproduction
- Navigate to the Executions view
- Add a new conditional group to the default set of filters
- Keep the
ORoperator - Add a new filer - e.g. labels
foo:bar - HTTP 400 response with:
Invalid query filters: Provided query filters are invalid: Field TIME_RANGE is not supported for resource EXECUTION. Supported fields are QUERY, SCOPE, FLOW_ID, START_DATE, END_DATE, STATE, LABELS, TRIGGER_EXECUTION_ID, CHILD_FILTER, NAMESPACE, KIND, PARENT_ID
Environment
- Kestra Version: develop
Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Assistant
I'll start by exploring the repository structure to understand the codebase.
Assistant
This is a Java project (Kestra). The issue is about conditional group filters. Let me search for the relevant filter-related files, particularly looking for "TIME_RANGE" and the filter validation logic.
Assistant
Let me look at the QueryFilter class and the validation logic that throws the "is not supported for resource" error.
Assistant
Let me look at the QueryFilter class structure, especially the
isNode()method and the children/conditional group fields.Assistant
Now I understand the structure. The
QueryFiltercan be a "leaf" (field + operation) or a "node" (logical + children) for conditional groups.The validation logic in
collectValidationErrorshandles the node case correctly:if (filter.isNode()) { filter.children().forEach(child -> collectValidationErrors(child, resource, errors)); return; }So the validation itself seems to handle conditional groups. But the error message says "Field TIME_RANGE is not supported for resource EXECUTION". This means a filter with field=TIME_RANGE is being validated somewhere.
Wait, the issue says "Add a new conditional group to the default set of filters". So the default set of filters probably includes a TIME_RANGE filter, and when the conditional group is added, the validation processes the entire filter list. But the error is about TIME_RANGE.
Let me think about this. The issue is that when you add a conditional group (an OR group with labels foo:bar), the validation fails because TIME_RANGE is not a supported field for EXECUTION resource.
Wait, but the validation should handle nodes correctly. Let me look at the webserver side to understand how the filters are being deserialized and validated.
Assistant
Let me look at how the webserver deserializes the filters and where the EXECUTION resource validation happens.
Assistant
Let me look at the existing tests for conditional groups in QueryFilterTest.
Assistant
Let me look at the test around line 748 which mentions node/EXECUTION:
Assistant
Let me look at the ExecutionController to understand how filters are processed.
Assistant
Let me look at the
QueryFilterUtils.replaceTimeRangeWithComputedDateFiltermethod.Assistant
Let me look at
TimeLineSearch.extractFrom:Assistant
Let me look at the other search endpoints in ExecutionController to see which ones call
replaceTimeRangeWithComputedDateFilter:Assistant
Let me look at how
findworks in the execution repository:Assistant
Let me write a reproduction test to confirm the issue:
Assistant
Let me look at the existing QueryFilterUtilsTest to understand the test setup:
Assistant
Let me examine the frontend to understand how filters are sent when a conditional group is added:
Assistant
The QuickFilters component handles timeRange separately. Let me look at where the filters are actually built and sent to the API. Let me search for how the filter query is constructed in the executions view.
Assistant
Let me focus on the backend. Let me look at the QueryFilterFormatBinderTest to understand how the URL params are parsed, especially for conditional groups:
Assistant
Let me look at the ExecutionControllerTest around line 452 to understand how the test reproduces the validation error:
Assistant
Let me find the
/searchendpoint:Assistant
Now let me verify the actual scenario by reproducing it. Let me look at the SearchableTest and the
filterlogic:Assistant
Let me look at the Searchable class to understand how it handles filters and nodes:
Assistant
Let me look at how the executions view builds the filter query params:
Assistant
Let me find the filter builder component that generates the
filters[query params:Assistant
Let me create a temporary reproduction test in the webserver testdirectory:
Assistant
I've reproduced the issue. The output shows that when
TIME_RANGEis inside a conditional group node, the replacement adds aSTART_DATEat top-level but leavesTIME_RANGEinside the node, causing validation failure. Let me confirm the frontend behavior by examining the filter builder:Assistant
This is interesting. The frontend uses a "tree" with
groups. Thetree.replaceTree([{id, kind: "leaf", filters: resetFilters}], "OR"). So the structure has a top-level logical operator ("OR") and groups.Let me look at
useRouteSyncto understand how the tree is converted to URL params.Assistant
Now I need to understand
encodeFilterGroupsToQueryandtree.topLogical. Let me look at the helpers:Assistant
I now fully understand the issue. When a conditional group is added, the frontend wraps ALL filters (including
timeRange) inside a top-level[or]group prefix (becauseonlyOneLeafbecomes false). SoTIME_RANGEends up nested inside a node, and the backend'sreplaceTimeRangeWithComputedDateFilter/TimeLineSearch.extractFrom/updateFiltersonly look at top-level leaves, leavingTIME_RANGEunreplaced → validation fails.Let me look at
DateUtils.validateTimelineand the full QueryFilterUtils to plan the recursive fix:Assistant
Let me look at
getConditionOnFieldin AbstractJdbcRepository to understand how START_DATE is handled:Assistant
Let me look at how START_DATE/END_DATE are handled in
getConditionOnField:Assistant
Let me check
dateFilterField()and the AbstractJdbcExecutionRepository fieldsMapping:Assistant
Let me check where
rewriteTriggerDateFiltersis used:Assistant
Let me check the BlueprintController and other controllers that use validateQueryFilters/Searchable:
Assistant
Let me check the LogController's use of replaceTimeRangeWithComputedStartDateFilter:
Assistant
Now I have a clear understanding. Let me implement the fix. First, let me modify
TimeLineSearch.extractFromto recurse into nodes:Assistant
Now let me modify
QueryFilterUtils.javato makeupdateFilters,updateFiltersForEndDate, andrewriteTriggerDateFiltersrecurse into nodes:Assistant
Now let me update
updateFilters,updateFiltersForEndDate, andrewriteTriggerDateFiltersto recurse into nodes:Assistant
Now let me update
updateFiltersForEndDateto recurse:Assistant
Now let me update
rewriteTriggerDateFiltersto recurse into nodes:Assistant
Now let me update
DateUtils.validateTimeline(List)to recurse into nodes:Assistant
Now let me run my reproduction test to see if the fix works:
Assistant
All three scenarios pass. Now let me write a more comprehensive test that uses the actual URL binder to simulate the exact frontend encoding, and verifies the full pipeline (binder → replaceTimeRange → validation):
Assistant
There's a compilation error. Let me see the actual error.
Assistant
The
getQueryFiltersis package-private in theconverterspackage. Let me move the test there:Assistant
The full pipeline works. Let me verify the parsed and replaced filters look correct:
Assistant
The fix works correctly. The
TIME_RANGEinside theANDnode (inside theORnode) is replaced withSTART_DATEin place. Now let me clean up the temporary tests and run the existing relevant test suites:Assistant
All passing. Now let me run the core QueryFilter tests and the JDBC repository tests:
Assistant
Now let me run the repository abstract tests (which use TIME_RANGE) via the jdbc-h2 module and the ExecutionControllerTest:
Assistant
All passing. Now let me run the ExecutionControllerTest which is the most relevant (it has the
badQueryFilterstest and the search endpoint):Assistant
Let me run the TriggerControllerTest and LogControllerTest to verify the trigger and log paths:
Assistant
Let me find the specific failing test:
Assistant
Let me re-run the tests to capture the exact failure:
Assistant
The failing test
shouldAcceptUnlockByIdsWithZeroItemsWhenUnlockedlooks like a test-pollution/shared-state issue, not related to my change. Let me verify by stashing my changes and running it:Assistant
With my changes stashed, TriggerControllerTest alone passes. The failure occurred when running BOTH tests together. Let me confirm this is pre-existing test pollution by running both together without my changes:
Assistant
Without my changes, both tests pass together. With my changes, one fails. Let me investigate the failing test. Let me look at the test around line 309:
Assistant
This test (
shouldAcceptDeleteTriggersByIdsWhenExist) doesn't involve filters. The failure may be flaky. Let me re-run with my changes a few times to check consistency:Assistant
Both runs pass now (45 passing) — the earlier failure was a flaky async test, not related to my change. Let me run a broader set of filter-related webserver tests to ensure no regressions:
Assistant
Let me check whether dashboards use the same TIME_RANGE replacement path or have a separate one that might need fixing:
Assistant
Let me check how dashboard filters are applied (whether they support nodes), to ensure my changes don't break or leave a gap:
Assistant
The dashboard uses
dataChartDatas.updateWhereWithGlobalFilters(filters, startDate, endDate). Let me checkupdateWhereWithGlobalFiltersto see if it handles nodes.But again, this is dashboard-specific. The issue is about the Executions view. Let me check
updateWhereWithGlobalFiltersquickly to see if it accesses.field()and would NPE on nodes, or if it handles nodes.Assistant
I see the dashboard's
whereWithGlobalFiltersusesf.field().equals(...)which would NPE on nodes — but that's a separate, pre-existing concern for the dashboard path (which receives filters via JSON body, not the URL binder). My change toTimeLineSearch.extractFromis strictly more capable and shouldn't break the dashboard's top-level case. Let me run the DashboardControllerTest to confirm:Assistant
Dashboard tests pass. Now let me check the
findDistinctFieldValuespath (used by the executions filter UI) which also receives filters but doesn't callreplaceTimeRange:Assistant
Let me check the
findDistinctFieldValuespath and whether the frontend sends timeRange to it. But first, let me write a temporary integration test that hits the actual/searchendpoint with a conditional group + timeRange to fully confirm the HTTP 400 is resolved:Assistant
Let me look at the distinct-field-values tests (line 375, 404) and search tests around line 446-460 to understand the test patterns. Let me look at lines 360-415.
Assistant
The
findDistinctFieldValuestests don't include timeRange, confirming the frontend sends only narrowing filters there. Now let me write a temporary integration test that hits the actual/searchendpoint with a conditional group + timeRange to confirm the HTTP 400 is resolved:Assistant
The
clientfield injection needs@Inject. Let me fix the test:Assistant
The integration test passes — the actual
/searchendpoint now accepts conditional groups with a nested timeRange. Let me verify the test fails WITHOUT my fix to confirm it reproduces the issue:Assistant
Confirmed: WITHOUT my fix the test fails (HTTP 400), WITH my fix both pass. Let me clean up the temporary test:
Assistant
Let me check all controllers using
@QueryFilterFormatand the TIME_RANGE utilities to ensure I've covered all paths:Assistant
The controllers using the TIME_RANGE utilities (Log, Execution, Trigger) all go through my fixed shared utilities. Let me verify the NamespaceController and KVController (which use
@QueryFilterFormatwithout TIME_RANGE) already handle nodes:Assistant
The Namespace and KV controllers use the in-memory
Searchable(which already handles nodes viaevaluate) and have no TIME_RANGE, so they're unaffected. My fix covers all affected paths (Execution, Log, Trigger).Let me do a final review of my changes:
Assistant
The diff looks clean. Let me verify there are no leftover temporary test files and run a final comprehensive test:
Assistant
Only the 3 source files are modified, no temp test files remain. Let me check if there's a DateUtils test and run a final comprehensive test:
Assistant
Let me run the tests properly, separating by module:
Assistant
All tests pass:
- core
QueryFilterTest: BUILD SUCCESSFUL - webserver (utils, converters, ExecutionControllerTest, DashboardControllerTest): 129 passing
- jdbc-h2 (Execution, Trigger, Log, Flow repository tests): 553 passing
My fix is complete and verified. Let me do a final review of the complete diff to ensure correctness:
- core
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.