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 analyze this issue step by step. The error message indicates that when a conditional group is added in the filters, the backend doesn't accept the
TIME_RANGEfield for EXECUTION resources.Let me start by exploring the repository structure.
Assistant
This is the Kestra project. Let me explore the structure further to understand the codebase.
Assistant
Let me look at the QueryFilter.java around the Field enum and supportedField method:
Assistant
Now let me look at the QueryFilterUtils.java to understand how the validation is done:
Assistant
Now let me find where the validation of the query filters happens:
Assistant
Now I understand the issue. The validation logic in
collectValidationErrorsworks correctly for non-node filters, but for node filters (those withlogicalandchildren), it only validates the children - but it doesn't validate them as a group.Let me check how the filter is sent from the frontend to better understand:
Assistant
Now let me check the encode filter code to understand how filters are encoded:
Assistant
Now let me look at the controllers that use validateQueryFilters:
Assistant
Now let me look at the existing test to understand the issue better:
Assistant
Now I understand the issue better. Let me reproduce the error. The error message says that when a conditional group with
ORoperator is created in the UI, and a filter likelabels foo:baris added, the backend returns an error saying thatTIME_RANGEfield is not supported for resource EXECUTION.Let me look at the front-end code to understand what is sent:
Assistant
Now I understand. By default, when the executions page is loaded, it adds a
filters[timeRange][EQUALS]filter to the URL. Then when the user adds a conditional group, the URL gets something likefilters[or][0][labels][EQUALS][foo]=bar.Let me look at how the URL query parameters are parsed by the backend:
Assistant
Now let me create a reproduction script to verify the issue:
Assistant
Wait - I think there's a simpler way to understand the issue. Let me look at what happens when the user adds a new conditional group.
In the UI:
filters[timeRange][EQUALS]=PT24His in the URL (from default)- User adds a filter inside a conditional group with OR
Assistant
Now let me look at the ExecutionController to understand the flow:
Assistant
Good. So the ExecutionController replaces TIME_RANGE filters with computed start dates, BUT, looking at the chain:
- The
searchExecutionscontroller method callsexecutionRepository.find() - The
find()method callsfilter()which callsQueryFilter.validateQueryFilters(filters, resource)BEFORE the time range replacement.
Wait, let me look at the order more carefully:
- The
Assistant
Let me see what happens in the ExecutionController:
Assistant
Now let me see how this gets called:
Assistant
Now let me see how
findPageis called and what happens there:Assistant
Now let me look at the ExecutionRepository to see what
computeFindConditiondoes:Assistant
Now let me trace what happens. When the user adds a conditional group, the URL becomes something like:
filters[timeRange][EQUALS]=PT24Hfilters[or][0][labels][EQUALS][foo]=bar
The query parameters parser then builds the filter tree:
- The first one has no prefix → goes to
directLeavesas a TIME_RANGE leaf - The second one has
[or][0]prefix → goes to a sub-node with logical=OR, index=0, which contains the labels leaf
So the parsed filter list becomes:
[TIME_RANGE leaf][OR node containing labels leaf]
Then in
validateQueryFilters:- It iterates over both top-level filters
- For the TIME_RANGE leaf, it tries to validate TIME_RANGE which isn't in EXECUTION.supportedField() - THIS IS THE ERROR!
Now let me reproduce the issue using the QueryFilterTest:
Assistant
Let me check the existing tests to understand the flow better:
Assistant
Now let me look at the QueryFilterFormatBinderTest more carefully to understand the URL parsing:
Assistant
Now I want to confirm my understanding. Let me see the validateQueryFilters again:
Assistant
Yes, the issue is clear now. The validation happens in
jdbc/.../AbstractJdbcRepository.java#filterBEFORE the time range replacement happens in the ExecutionController. Wait, but the ExecutionController DOES replace the time range filter:Let me re-check. Looking at
ExecutionController.searchExecutions:javaQueryFilterUtils.replaceTimeRangeWithComputedDateFilter(filters, dateFilter),But this happens AFTER the binder parses the URL into
List<QueryFilter>. The binder produces the filters with TIME_RANGE leaf at the root level (because timeRange has no prefix). The ExecutionController then callsreplaceTimeRangeWithComputedDateFilterwhich replaces it with START_DATE.But the issue is that the replace function only replaces the direct leaves. Let me check:
Assistant
OK so
replaceTimeRangeWithComputedDateFilteris called BEFORE the filters get toexecutionRepository.find. Let me trace wherefindvalidates the filters:Assistant
OK so this all happens AFTER
replaceTimeRangeWithComputedDateFilter. So actually the time range SHOULD be replaced before validation. Let me check what's happening.Wait, looking again at
ExecutionController.searchExecutions:javapublic PagedResults<ApiLightExecution> searchExecutions( ... @QueryFilterFormat(Resource.EXECUTION) List<QueryFilter> filters, @Nullable @QueryValue DateFilter dateFilter ) { var executions = executionRepository.find( PageableUtils.from(page, size, sort, executionRepository.sortMapping()), tenantService.resolveTenant(), QueryFilterUtils.replaceTimeRangeWithComputedDateFilter(filters, dateFilter), dateFilter );Assistant
OK so the filter replacement IS happening. Let me dig deeper. What about when the user adds the conditional group? Let me look at what happens when there is a label filter inside an OR group and the time range is at root level.
Looking at
replaceTimeRangeWithComputedDateFilter:- It calls
TimeLineSearch.extractFrom(filters) - Then
updateFilters(filters, resolvedDate)which iterates and replaces timeRange → startDate leaf at root.
The function should replace the time range filter at root level with a START_DATE filter. Let me verify by examining the
updateFilters:- It calls
Assistant
OK so the issue is when there's only ONE filter (TIME_RANGE leaf) and you add a conditional group like OR containing labels, what does the binder do? Let me trace again with the actual values.
Looking at the binder logic again with my example URL:
filters[timeRange][EQUALS]=PT24H- prefix is empty
Assistant
Let me trace what happens when validation happens at AbstractJdbcRepository level. The flow is:
searchExecutionsis called with filters that have TIME_RANGE leaf at root and OR node childreplaceTimeRangeWithComputedDateFilter(filters, dateFilter)is called- The TIME_RANGE leaf should be replaced with START_DATE leaf
So the validation should pass. Unless there's something I'm missing. Let me look at
replaceTimeRangeWithComputedDateFilterone more time and trace it carefully:Actually, looking at the code flow,
replaceTimeRangeWithComputedDateFilteris supposed to convert the TIME_RANGE leaf to START_DATE leaf, BUT the issue is that when this is called, the function only modifies the top-level list. Let me verify.Wait, the test for time range replacement was:
javavar filters = timeRangeFilter(); // [TIME_RANGE leaf] var result = QueryFilterUtils.replaceTimeRangeWithComputedDateFilter(filters, DateFilter.START_DATE); assertThat(result).hasSize(1); assertThat(result.get(0).field()).isEqualTo(QueryFilter.Field.START_DATE);Assistant
Now let me look more carefully at the issue. Let me look at the binder code again - the way the URL is being parsed:
Assistant
Now let me write a reproduction test in Java to verify the issue:
Assistant
Let me write a test that more accurately reproduces the flow:
Assistant
Let me use a simpler approach - add a test that uses the actual project structure:
Assistant
Let me write the reproduction as a real test in the project to see the actual error:
Assistant
The test passed but I need to check the output. Let me look at the build report:
Assistant
I've confirmed the error. The validation fails because TIME_RANGE leaf at root level fails validation BEFORE the time range replacement happens (in the JDBC layer).
Now I understand the full picture. The flow is:
- URL has
filters[timeRange][EQUALS]=PT24Handfilters[or][0][labels][EQUALS][foo]=bar - The binder parses these into
[TIME_RANGE leaf, OR node with labels leaf] - In ExecutionController,
replaceTimeRangeWithComputedDateFilterreplaces TIME_RANGE with START_DATE leaf - The result is
[START_DATE leaf, OR node with labels leaf] - This goes to the JDBC repository, which calls
validateQueryFilters- should pass.
But wait, the error says TIME_RANGE is being validated. So either:
- The replacement isn't happening
- The validation is happening before the replacement
Let me check if there's something else going on. Maybe the issue is that when the user adds the conditional group, the time range might be inside the OR group, not at root level.
- URL has
Assistant
Now let me look at the UI code to understand how the time range filter is added in conditional group:
Assistant
Let me check the UI test to see how the URL is constructed:
Assistant
OK so looking at this test, I see the structure. Now the URL
filters[timeRange][EQUALS]would NOT be the case for the conditional group because if you have a conditional group, the URL would befilters[or][0][labels][EQUALS][foo]=bar.Let me look at the actual issue more carefully. Maybe the issue is that there's also a top-level time range filter that remains. Looking at the test case
testRemainBackwardCompatibleWithFlatLegacyFormat, the URL hasfilters[timeRange][EQUALS]ANDfilters[flowId][IN]- both flat (no prefix).In our case, when the user adds a conditional group with a labels filter, the URL becomes:
filters[timeRange][EQUALS]=PT24H(still at root level since it was there before)filters[or][0][labels][EQUALS][foo]=bar(the new conditional group)
The binder parses this to:
- root.directLeaves = [TIME_RANGE leaf]
- root.subNodes[OR][0].directLeaves = [labels leaf]
Then
replaceTimeRangeWithComputedDateFilteris called. It should iterate the top-level filters and replace the TIME_RANGE leaf.Let me write a test that simulates this with the binder:
Assistant
I need to convert it to a JUnit test:
Assistant
This confirms the situation. The replacement DOES happen, so the validation passes when the replacement is done correctly. So the issue must be elsewhere.
Let me think about this... The issue title says "Backend do not accept conditional groups" - so when a conditional group is added, the request fails. Let me look at what specifically happens when the time range is INSIDE a conditional group.
Let me check if the UI could be putting time range inside the conditional group:
Assistant
So time range is at the top level. Let me trace the actual reproduction case once more.
Wait! Let me look at the issue more carefully. The user says "Keep the OR operator" - this implies there was already a default set of filters. Let me look at the initial state of the page:
Assistant
Let me look at how the executions page specifically handles default filters:
Assistant
OK so the default time range is
filters[timeRange][EQUALS]=PT24H.Let me check the Executions.vue to see if there are any other filter parameters:
Assistant
OK so the default behavior for executions:
filters[timeRange][EQUALS]=PT24H(default time range)filters[state][IN]=RUNNING,SUCCESS,FAILED,CANCELLED,KILLED,SKIPPED,WARNING,PAUSED,QUEUED,RETRYING,RESUMING,RETRIEVING,KILLING,CANCELING,PAUSING,RESUMING(default state filter from visibleByDefault)
Hmm, the state filter has
visibleByDefault: true. Let me check how this gets encoded. Now if you also add a conditional group, the URL would be:filters[state][IN]=...filters[timeRange][EQUALS]=PT24Hfilters[or][0][labels][EQUALS][foo]=bar
Let me think... when validation happens, the state and timeRange are direct leaves, and labels is in an OR group. After replace, TIME_RANGE → START_DATE. So validation should pass.
Wait, let me check if there's a
log/or other path where the time range replacement might not be applied:Assistant
OK so
findAsyncis called directly with filters. Let me check if there's a place where the time range filter isn't replaced:Assistant
OK that one is also doing the replacement. Let me look at other places that handle EXECUTION filters:
Assistant
Let me look at the most common calls in the controller and see if they all do the time range replacement:
Assistant
OK so all these controllers do
replaceTimeRangeWithComputedStartDateFilter. But the issue says it fails with TIME_RANGE field error.Let me think about this from a different angle. Maybe the time range filter is being PUT INSIDE the conditional group by the UI, not at the root level. Let me look at the UI code that handles putting filters in conditional groups:
Assistant
Now let me check
useRouteSync.ts:Assistant
Now let me think about this. The flow seems correct. Let me look more carefully. Let me try a different scenario - what if
timeRangeis the only filter at first, and then a conditional group is added? Looking at the code:javaAssistant
PERFECT! Now I've confirmed the bug:
- When you add a conditional group, the UI sends
filters[or][0][timeRange][EQUALS]=PT24Handfilters[or][1][or][0][labels][EQUALS][foo]=bar(i.e., the timeRange filter gets wrapped in an OR group because it's now part of a wrapper) - The binder parses these into a top-level OR node containing [TIME_RANGE leaf, OR node with labels leaf]
- The
replaceTimeRangeWithComputedDateFilteronly replaces the top-level TIME_RANGE filters but NOT those nested in groups - So the TIME_RANGE leaf inside the OR group remains
- When validation happens, the TIME_RANGE leaf fails
Let me also confirm that the UI does this by checking the encode function:
- When you add a conditional group, the UI sends
Assistant
No node available, but I already know from looking at the code that:
encodeFilterGroupsToQueryaddsfilters[or][N]prefix to each group when there's more than one group- So the timeRange inside the leaf group gets the prefix
filters[or][0] - The labels inside the wrapper's child also gets nested prefix
Looking at the parsePrefixChain function, the binder handles up to MAX_RENDERABLE_NESTING_DEPTH groups. Let me check what that is:
Assistant
OK so MAX_RENDERABLE_NESTING_DEPTH is 2. Now let me verify by looking at the UI test again:
Assistant
Now I confirm: when there are multiple top-level groups, the existing top-level filters get a
filters[or][0]prefix. So the time range that was at top level getsfilters[or][0][timeRange][EQUALS]=PT24H.Now I understand the fix. The fix should be in
replaceTimeRangeWithComputedDateFilter(and the END_DATE variant) to recursively handle nested TIME_RANGE filters within nodes.Let me look at the function once more:
Assistant
Now I see the bug. The
updateFiltersandupdateFiltersForEndDatemethods only iterate top-level filters. When a TIME_RANGE leaf is nested inside a group, it isn't replaced.Let me also verify the TimeLineSearch to ensure it can extract nested TIME_RANGE:
Assistant
OK TimeLineSearch also doesn't recurse into nested filters. So even the timeline info wouldn't be extracted.
Now I need to fix both
replaceTimeRangeWithComputedDateFilterandTimeLineSearch.extractFrom. Let me think about the best approach.There are two approaches:
- Fix the UI: Make sure the time range filter is always at the top level, not inside groups.
- Fix the backend: Make
replaceTimeRangeWithComputedDateFilterandTimeLineSearch.extractFromhandle nested TIME_RANGE filters.
Looking at the UI behavior, the time range IS at the top level for a single leaf group, but when a wrapper group is added, the existing time range filter gets wrapped in a top-level wrapper.
Let me check the UI test for this behavior:
Assistant
Let me look at how to fix this. The cleanest approach is to fix the backend to handle nested TIME_RANGE filters. Let me look at the TimeLineSearch first:
Assistant
Now let me look at the test for TimeLineSearch:
Assistant
Now let me think about the best fix. Let me check if there are any other places that might need to be updated to handle nested filters.
I think the cleanest fix is to:
- Update
replaceTimeRangeWithComputedDateFilterto recursively traverse the filter tree - Update
TimeLineSearch.extractFromto recursively traverse the filter tree
Actually, looking more carefully, I think the cleaner approach is to fix the UI to handle this case, since TIME_RANGE is logically a top-level filter and shouldn't be part of a conditional group. But changing the UI is risky.
Let me think about this differently. Let me look at how the dateFilter works - maybe the time range should always be processed before the actual filtering. Looking at the controller code,
replaceTimeRangeWithComputedDateFilteris called BEFORE the filters reach the JDBC layer. The fix should be inreplaceTimeRangeWithComputedDateFilter(and similar functions) to recursively handle nested filters.Let me also check if there are any other code paths:
- Update
Assistant
Let me look at how validateTimeline handles nested filters:
Assistant
OK so
DateUtils.validateTimelineis also not recursive. So the bug is more widespread than I thought. Let me design the fix.The best approach is to:
- Update
TimeLineSearch.extractFromto recursively traverse nested filters - Update
QueryFilterUtils.updateFiltersandupdateFiltersForEndDateto recursively traverse nested filters - Update
QueryFilterUtils.rewriteTriggerDateFiltersto recursively traverse nested filters - Update
DateUtils.validateTimelineto recursively traverse nested filters
Let me also check the
findAsyncand other places that might process TIME_RANGE:- Update
Assistant
OK so at the JDBC level, if TIME_RANGE filter is processed, it calls
timeRangeConditionwhich throws an exception. But the validation happens BEFORE the conversion so the issue is at validation.Now let me design the fix. The cleanest approach is to recursively process nested filters. Let me update the code:
First, let me check the tests structure for
updateFilters:Assistant
Now let me think about the best fix.
Looking at the existing code more carefully, I think the cleanest solution is to update the
replaceTimeRangeWithComputedDateFilter(and related) to recursively traverse the filter tree. Let me also checkrewriteTriggerDateFilters:Assistant
OK now I'll write the fix. The plan is:
- Update
TimeLineSearch.extractFromto recursively traverse nested filters - Update
QueryFilterUtils.updateFiltersto recursively traverse nested filters - Update
QueryFilterUtils.updateFiltersForEndDateto recursively traverse nested filters - Update
QueryFilterUtils.rewriteTriggerDateFiltersto recursively traverse nested filters - Update
DateUtils.validateTimelineto recursively traverse nested filters
Let me delete my test files first since I'm not supposed to add tests:
- Update
Assistant
Good, my test files are removed. Now let me implement the fix.
First, let me fix
TimeLineSearch.extractFrom:Assistant
I accidentally deleted too much. Let me restore:
Assistant
Now let me apply the fix correctly:
Assistant
Good. Now let me update
QueryFilterUtils.javato handle nested filters:Assistant
Now let me apply the fix to the
updateFiltersandupdateFiltersForEndDatemethods:Assistant
Now let me also fix
rewriteTriggerDateFiltersand add the helper methods:Assistant
Wait, there's a name collision - both methods are named
containsDateBoundary. Let me fix:Assistant
Now let me also update
DateUtils.validateTimelineto handle nested filters:Assistant
Now let me also fix the validation logic in QueryFilter.java to validate fields in nested nodes as well. Actually, looking at the validation again:
Assistant
Good. The validation is already recursive - it goes through node children. So the validation IS being applied recursively. The issue was that the TIME_RANGE filter reached the validation step because the replaceTimeRangeWithComputedDateFilter wasn't replacing nested TIME_RANGE filters.
Now let me build and run the tests:
Assistant
Right, I need to convert the stream to iterable. Let me fix:
Assistant
I see there's a duplicate
allLeavesmethod. Let me remove it:Assistant
Let me remove the duplicate. Also, let me make the for-each cleaner by using a different approach:
Assistant
I need to remove the duplicate at lines 146-154. Let me try again with a more precise range:
Assistant
Let me try a different approach using sed:
Assistant
The duplicate is removed. Now let me also check the imports - I need to make sure
QueryFilteris imported:Assistant
Good. Now let me also try building:
Assistant
Now let me build the webserver:
Assistant
Same issue. Let me fix:
Assistant
Now let me run the existing tests:
Assistant
Hmm, the test failed. Let me see what the test expects:
Assistant
The test
testUpdateFiltersKeepsUnrelatedFilterschecks that:- START_DATE filter stays as is (just updated to newStartDate)
- END_DATE filter stays as is
- TIME_RANGE filter gets converted to START_DATE with GREATER_THAN_OR_EQUAL_TO
With my changes, the START_DATE filter is being updated too (the operation should remain EQUALS but value should be newStartDate). Let me look at my code:
javaprivate static QueryFilter rewriteDateLeaf(QueryFilter leaf, QueryFilter.Field target, ZonedDateTime resolvedDate) { if (isTimeRangeFilter(leaf)) { return QueryFilter.builder() .field(target) .operation(timeRangeOperation(leaf)) .value(resolvedDate.toString()) .build(); } if (isStartDateFilter(leaf) || isEndDateFilter(leaf)) { return QueryFilter.builder() .field(target) .operation(leaf.operation()) .value(leaf.value()) .build(); } return leaf; }Assistant
Looking at the test
testUpdateFiltersKeepsUnrelatedFilters:- START_DATE filter (EQUALS) → START_DATE filter (EQUALS) with newStartDate value
- END_DATE filter (EQUALS) → END_DATE filter (EQUALS) with endDate value
- TIME_RANGE filter (EQUALS) → START_DATE filter (GREATER_THAN_OR_EQUAL_TO) with newStartDate value
But in my fix, when START_DATE filter is the input, I use
createUpdatedStartDateFilterwhich callscreateUpdatedDateFilterand the operation stays EQUALS, value becomes newStartDate. That's correct.When END_DATE filter is the input, my code maps it to
createUpdatedStartDateFilterwhich means it's converted to START_DATE! That's wrong. The END_DATE filter should stay as END_DATE.Let me look at the original code:
javaAssistant
I see, the issue is that
mapTimeRangeFilterwas applying the leafMapper to ALL date-boundary filters (including END_DATE), butcreateUpdatedStartDateFilterwould convert END_DATE → START_DATE.The problem is the
mapTimeRangeFilteris generic and used by multiple callers. Let me restructure so each caller specifies exactly which filters it wants to map.Let me change the approach. I'll add a "should map" predicate to the helper:
Assistant
Now I need to update
updateFiltersForEndDateand themapTimeRangeFilterhelper to accept a predicate:Assistant
I have a duplicate javadoc. Let me clean up:
Assistant
Now I need to update
mapTimeRangeFilterto accept a predicate andrewriteTriggerDateFiltersto use the predicate:Assistant
Now I need to fix the call to
mapTimeRangeFilterinrewriteTriggerDateFilters:Assistant
I see there's an extra
}. Let me fix that:Assistant
Let me look at the file:
Assistant
I need to add a blank line between
}and/**:Assistant
Now let me run the tests:
Assistant
All tests pass. Now let me write a reproduction script to confirm the fix works:
Assistant
Wait, I shouldn't add tests! Let me remove this and instead verify with the existing test setup:
Assistant
Now let me run the broader test suite to make sure nothing breaks:
Assistant
All tests pass. Now let me also run the QueryFilterTest in core:
Assistant
Now let me also run the JDBC tests to make sure my changes don't break them:
Assistant
All JDBC tests pass. Now let me create a temp file to actually verify my fix works by running a manual test:
Assistant
Let me fix the test:
Assistant
Ah, getQueryFilters is package-private. Let me use Map.of instead of HashMap since the parameter type is
Map:Assistant
The error message says the method doesn't match. Let me look at what package it is in:
Assistant
The method is package-private. My test file is in
io.kestra.webserver.utilsbut the method is inio.kestra.webserver.converters. Let me move the test:Assistant
The fix works. Let me check the output:
Assistant
The fix works. The TIME_RANGE leaf inside the OR group is correctly converted to START_DATE leaf, and validation passes.
Now let me delete the temp test file:
Assistant
Now let me think about edge cases:
- Empty filter list: Should work correctly because
containsDateBoundary(null)returns false andTimeLineSearch.extractFrom(empty)returns default. - TIME_RANGE nested in wrapper: Now handled.
- TIME_RANGE nested in wrapper nested in wrapper: Now handled (recursive).
- END_DATE inside group: For
updateFilters, my code only handles START_DATE and TIME_RANGE (not END_DATE). ForupdateFiltersForEndDate, my code only handles TIME_RANGE. So END_DATE inside a group is preserved. - START_DATE inside group for START_DATE mode: Handled (since my predicate is
isStartDateOrTimeRange). - START_DATE inside group for END_DATE mode: Not handled by
updateFiltersForEndDate. This matches the original behavior - the original code also only modified START_DATE or TIME_RANGE filters when updating filters.
Let me also check if there's a similar issue with
findAsync:- Empty filter list: Should work correctly because
Assistant
OK these all use
replaceTimeRangeWithComputedStartDateFilterwhich is now fixed.Let me also look at where else
validateTimelineis called - especially for nested filters:Assistant
OK
validateTimeline(List)is called fromQueryFilterUtils.validateTimelinewhich is called at line 130 (validateTimeline(updatedFilters)). This is now fixed.Let me check the LogController:
Assistant
LogController has the same issue. Let me check if the searchLogs endpoint uses
replaceTimeRangeWithComputedStartDateFilter:Assistant
Good, line 83 uses it. The other endpoints (
findAsync,buildExecutionFilters) are for specific execution IDs and don't need time range replacement.Let me also check TriggerController:
Assistant
Good.
rewriteTriggerDateFiltersis also fixed. Now let me also check the JDBC trigger repo:Assistant
OK that's a different concept - ISO-8601 duration for trigger date. Not related.
Now let me run the broader webserver tests:
Assistant
All 880 webserver tests pass! Let me also run the core tests:
Assistant
Now let me also think about additional edge cases. The issue says it returns HTTP 400 with "TIME_RANGE is not supported". Let me see if the same issue could happen with the validation logic itself. Looking back at the issue:
When the user adds a conditional group:
- URL:
filters[timeRange][EQUALS]=PT24H&filters[or][0][labels][EQUALS][foo]=bar - After parsing:
[TIME_RANGE leaf, OR node with labels leaf] replaceTimeRangeWithComputedDateFilterreplaces TIME_RANGE with START_DATE- Result:
[START_DATE leaf, OR node with labels leaf] - Validation: should pass
Wait, this case is what I tested in ReproTest (the first one). Let me re-read what happens with
or[0]prefix. Let me actually look at the binder code again:- URL:
Assistant
So the binder does keep the time range at root level if it has no prefix. Now what if the UI adds a prefix to it? Let me re-check the UI encode logic:
Assistant
I see. So when there are multiple groups, the timeRange does get the prefix
filters[or][0]. So my fix is needed.Now let me think about whether I need to also update the validation logic in QueryFilter.java. Let me look at it again:
Assistant
Good -
collectValidationErrorsalready recursively walks through node children, so the validation will catch any TIME_RANGE leaf that slips through. That's what happens in the bug.Now let me also check the validation more thoroughly. Looking at the error message in the issue:
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
This confirms that the TIME_RANGE leaf was being validated. My fix prevents this by recursively replacing TIME_RANGE → START_DATE in nested groups.
Let me also look at the
ExecutionControllerTestto see if there are existing tests for the bug:Assistant
OK there's a test
badQueryFiltersthat tests invalid filters. This isn't related to my change.Let me now check if there are any places where I might have missed updating. Let me check the tests:
Assistant
All tests pass. Let me also look at the final state of the files to ensure correctness:
Assistant
Let me clean up that missing blank line:
Assistant
I have an extra blank line. Let me clean it up:
Assistant
Now I broke the file. Let me restore and fix properly:
Assistant
I need to reapply the changes. Let me do it carefully:
Assistant
I have a duplicate javadoc. Let me fix:
Assistant
Now I need to update
rewriteTriggerDateFiltersand add the helper methods. Let me view the bottom of the file:Assistant
Now let me update
rewriteTriggerDateFiltersand add the helper methods:Assistant
Now the file looks good. Let me build and run tests:
Assistant
All 22 tests pass. Now let me run the more comprehensive tests to ensure nothing else is broken:
Assistant
Tests are taking too long. Let me just run the most relevant tests:
Assistant
All 96 tests in the webserver.utils and webserver.converters packages pass.
Let me also run the ExecutionControllerTest which is the most relevant test:
Assistant
23 tests pass.
Let me also look at the final state of the files to ensure everything is consistent:
Assistant
I have an extra blank line in DateUtils. Let me fix:
Assistant
Now let me look at the other diffs:
Assistant
The diffs look good. Let me run all the related tests one more time:
Assistant
All 96 tests pass. Let me also verify that the
LogControllertests pass:Assistant
Now let me run the TriggerController tests:
Assistant
All tests pass. Now let me also run the core tests:
Assistant
Now let me think about any other places where the bug could manifest. Let me search for places that handle EXECUTION or LOG filters without the time range replacement:
Assistant
Let me check the LogController to see if it handles all filter calls consistently:
Assistant
Only the searchLogs endpoint (line 83) calls
replaceTimeRangeWithComputedStartDateFilter. The other endpoints usebuildExecutionFilterswhich is for execution-specific logs (executionId is part of the URL). So they don't have a time range to replace. This is fine.Now let me think about additional edge cases:
- What if the user has multiple time ranges in different groups? Let me test:
Assistant
Both edge cases pass. Let me check the test output:
Assistant
Excellent! Both edge cases work correctly:
- Deeply nested TIME_RANGE (3 levels of groups) is correctly converted
- When there's no time range, a default START_DATE filter is added at the root level (this matches the original behavior)
Now let me clean up the test file:
Assistant
Let me also check git status to see all the changes:
Assistant
Only 3 files changed:
core/src/main/java/io/kestra/core/utils/DateUtils.java- FixedvalidateTimeline(List)to recursively traverse nested filterswebserver/src/main/java/io/kestra/webserver/utils/QueryFilterUtils.java- FixedupdateFilters,updateFiltersForEndDate,rewriteTriggerDateFiltersto recursively handle nested filterswebserver/src/main/java/io/kestra/webserver/utils/TimeLineSearch.java- FixedextractFromto recursively traverse nested filters
Let me also do a final check to make sure my changes are complete and correct:
Assistant
The diffs look clean. Now let me run all tests one more time to ensure everything passes:
Assistant
All 96 tests pass.
Let me think about the issue description checklist:
If an error was reported in the issue description, I have successfully reproduced it.
I did reproduce the error - I wrote a test that confirmed:
- Before fix:
Field TIME_RANGE is not supported for resource EXECUTIONerror - After fix: validation passes
If an error was reported in the issue description, I have confirmed that my fix resolves the error.
Yes, my fix resolves the issue. The TIME_RANGE leaf nested inside the conditional group is now correctly converted to START_DATE before validation.
- Before fix:
Assistant
Good. The validation recursively walks through children. So if my fix replaces TIME_RANGE → START_DATE inside a group, the validation will validate the START_DATE leaf which is supported.
Let me run the relevant tests one more time:
Assistant
All tests pass. Let me also verify there are no compilation issues anywhere:
Assistant
All compiles successfully.
Let me also verify the JDBC module compiles:
Assistant
Everything compiles successfully.
Now let me also check that the imports look clean:
Assistant
All imports look good.
Let me now also look at the documentation file for QueryFilter to make sure it's still up to date. Actually, let me skip that since I haven't changed any public API surface.
Let me also look at the JDBC tests one more time:
Assistant
All 30 JDBC tests pass.
Now let me think about whether I missed anything else. Let me check if there are any UI changes that might be needed:
Assistant
The UI side has multiple handling of TIME_RANGE, but my fix is on the backend so the UI doesn't need to change.
Let me also see if there are any related places in the codebase I might have missed:
Assistant
OK the
timeRangeConditionwould throw an exception if called with a TIME_RANGE filter. But that's a safety net for cases where TIME_RANGE isn't properly replaced. The validation would happen first.Now let me check the final state of everything:
Assistant
Only the 3 files are modified, which is exactly what I intended. Let me make sure the changes look clean by viewing the final state of each:
Assistant
Everything looks good. The fix is clean and consistent.
Let me also run a final sanity check by running all the tests one more time:
Assistant
Tests are up to date from cache. Let me re-run with --rerun-tasks:
Assistant
All 96 tests pass.
Now let me also think about whether the UI behavior change should be made too. Looking at the issue again:
- 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:
The user adds a conditional group with OR operator and adds a labels filter inside it. This causes the URL to have the time range wrapped inside an OR group. My fix is the right approach because:
- The UI structure is reasonable - filters can be at the top level or in groups
- The backend should handle TIME_RANGE in nested groups
- Changing the UI to keep time range always at root level could break other features
Let me also check if there's anything related to the
parseEncodedGroupsfunction in the UI:Assistant
OK that's just UI decoding. The UI behavior is fine - it encodes correctly. The backend now handles the nested TIME_RANGE properly.
Now let me think about whether the issue might be related to the JavaScript side too. Let me look at the original issue more carefully:
Looking at the UI's encode function:
javascriptconst onlyOneLeaf = groups.length === 1 && !isWrapperGroup(groups[0])If there's only ONE top-level leaf group (no wrapper), the prefix is
filters. Otherwise, it'sfilters[or][N].So when the user starts with only the default time range (1 leaf), the URL is
filters[timeRange][EQUALS]=PT24H.When the user adds a conditional group, the groups array becomes:
Assistant
Three files changed, 108 insertions, 29 deletions. The fix is clean and focused.
Now let me look at the checklist items:
- If an error was reported in the issue description, I have successfully reproduced it.
I successfully reproduced the error:
- Before fix:
Field TIME_RANGE is not supported for resource EXECUTIONerror - After fix: validation passes
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
Confirmed. My fix recursively replaces TIME_RANGE → START_DATE inside nested groups, so validation passes.
Assistant
Let me address the checklist one more time, with reasoning:
- If an error was reported in the issue description, I have successfully reproduced it.
Reasoning: I created a reproduction test (in
webserver/src/test/java/io/kestra/webserver/converters/ReproTest.javawhich I then deleted to follow the instruction not to add tests) that confirmed the error:Field TIME_RANGE is not supported for resource EXECUTION.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error. : After my fix, the same reproduction test passes - the TIME_RANGE leaf nested inside the OR group is now correctly converted to START_DATE before validation, so validation passes.
- If an error was reported in the issue description, I have successfully reproduced it.
Reasoning: I created a reproduction test (in
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.