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
Let me start by exploring the repository structure to understand what we're working with.
Assistant
This is the Kestra repository. The issue is about the Backend not accepting conditional groups in filters. The error message indicates that the field TIME_RANGE is not supported for resource EXECUTION. Let me explore the structure to find the relevant code
Assistant
Now let me search for the filter-related code, especially anything related to TIME_RANGE:
Assistant
me see the entire file to understand the full structure:
Assistant
me look at the frontend code to understand how the conditional group filter is constructed:
Assistant
Let me search for how filters are being sent to the backend:
Assistant
Let me look at the ExecutionController to see how the conditional group filter is handled:
Assistant
Now let me look at how the URL parameter
filtersis parsed:Assistant
let me check the conversion code:
Assistant
Now let me find where the validation happens:
Assistant
let me look at where the validation happens -
validateQueryFiltersis called inAbstractJdbcRepository.java:Assistant
Let me check the order of operations more carefully:
Assistant
Now let me look at the
TimeLineSearch:Assistant
I see!
TimeLineSearch.extractFromalso doesn't handle nodes with children. It just iterates over the flat list. But wait - if a TIME_RANGE is inside a node (child), this extraction won't find it, so it will not be considered.Now let's look at the ExecutionRepository find method to confirm this
Assistant
Let me look at the
findmethod ofAbstractJdbcExecutionRepository:Assistant
Let me write a script to reproduce the issue first:
Assistant
Let me look at the binder tests to see how they structure conditional group tests:
Assistant
Let me check if there's a way to run tests directly:
Assistant
first try to compile and test the issue using a test file:
Assistant
create a temporary test file to reproduce the issue:
Assistant
Let me see the output of the test to understand what's happening:
Assistant
me check the test report file to see the actual output:
Assistant
I've confirmed the bug! The output shows:
- The OR group still contains a TIME_RANGE filter (not replaced)
- A START_DATE filter was incorrectly added at the root level
Now let me look at the existing tests to understand what should be preserved:
Assistant
Let me check how the frontend constructs these queries:
Assistant
Now let me clean up the test file and implement the fix:
Assistant
Let me also check
DateUtils.validateTimeline:Assistant
Now let me look at any other related places where these filters are processed:
Assistant
Now I have a clear understanding. Let me design the fix:
TimeLineSearch.extractFromneeds to traverse into children of nodesQueryFilterUtils.updateFiltersneeds to traverse into children of nodesQueryFilterUtils.updateFiltersForEndDateneeds to traverse into children of nodesQueryFilterUtils.rewriteTriggerDateFiltersneeds to traverse into children of nodesDateUtils.validateTimeline(List<QueryFilter>)needs to traverse into children of nodes
Let me start with the
QueryFilterUtils.javafix:Assistant
Now let me look at the
TimeLineSearchfile again:Assistant
Now I'll implement the fix. Let me start with
TimeLineSearch.java:Assistant
I need to actually invoke the tool calls to make the edits. Let me start by writing the fix for
TimeLineSearch.javafirst.Assistant
Let me write the fix for
TimeLineSearch.javafirst:Assistant
Now let me update
QueryFilterUtils.javato handle conditional groups recursively:Assistant
made a mistake. Let me restore the file:
Assistant
Good, file is restored. Now let me make the changes more carefully. First, let me update the imports:
Assistant
I broke the line 15 again. Let me restore.
Assistant
Now let me update the
updateFiltersmethod:Assistant
Now let me update the
updateFiltersForEndDatemethod:Assistant
Now let me update
rewriteTriggerDateFilters:Assistant
are two
}at the end. Let me fix that.Assistant
replace added some extra lines. Let me fix it.
Assistant
Let me check the current state of the file:
Assistant
The replacement didn't work properly. Let me try once more with a different line range:
Assistant
Now let me check the beginning of the file:
Assistant
Now let me update
DateUtils.validateTimelineto handle nodes:Assistant
Let me clean up:
Assistant
me restore the file and try again with a different approach:
Assistant
Now let me make a more targeted edit:
Assistant
There are issues. Let me restore and start fresh:
Assistant
Now let me make a targeted edit. I'll just modify the loop to walk into children:
Assistant
There are leftover lines from the old method. Let me clean up:
Assistant
The file is even more broken. Let me write the whole file from scratch:
Assistant
let me check the QueryFilterUtils.java:
Assistant
Now let me create the test file to reproduce and verify the fix:
Assistant
Let me see the compilation errors:
Assistant
local variables need to be effectively final. Let me use an array:
Assistant
issue with
TimeLineSearch. Let me fix that too:Assistant
The test passes. Let me verify by checking the output:
Assistant
Assistant
All 3 tests pass. Let me check the actual output of the test cases:
Assistant
All three test cases work correctly. Now let me also run the existing related tests to make sure I didn't break anything:
Assistant
All 81 tests pass. Now let me also check the
QueryFilterTestin the core module to make sure I haven't broken anything:Assistant
All 730 tests pass. Let me now also run the
QueryFilterFormatBinderTestto make sure the URL parameter parsing still works:Assistant
All 15 tests pass. Let me also run the
TimeLineSearchTest:Assistant
Now let me check the JDBC test repository tests:
Assistant
me also test the AbstractExecutionRepositoryTest:
Assistant
also check the
TimeLineSearchTestcarefully to ensure my changes don't break it:Assistant
Now let me also run the LogRepository tests:
Assistant
Let me also check the controller tests that may be affected by my change:
Assistant
Let me run a broader test to make sure nothing is broken:
Assistant
All tests pass. Now let me also check that I have not broken anything in the LogController:
Assistant
Let me also create a test for the binder to verify the URL parameter binding works:
Assistant
Let me move the test to the converters package:
Assistant
Both tests pass. Let me check the output to confirm the fix:
Assistant
Excellent! The output shows both scenarios work correctly:
- Test 1: TIME_RANGE only inside a conditional group → replaced with START_DATE inside the AND group
- Test 2: TIME_RANGE at root + OR group with LABELS → TIME_RANGE replaced at root, OR group preserved
Let me clean up the temp test file and verify the fix once more:
Assistant
Now let me look at the final state of the files I modified:
Assistant
me check if
isStartDateFilterandisEndDateFilterinDateUtilsare used elsewhere:Assistant
methods are now dead code. Let me check if they're used in tests:
Assistant
me leave those methods as they don't cause issues. Now let me also verify that the fix works in the more general case by running more tests:
Assistant
All tests pass. Now let me also check the ExecutionControllerTest tests:
Assistant
The
badQueryFilterstest passes. Let me now also check the LogController tests:Assistant
Let me also check the JDBC repository tests since that's where the validation happens:
Assistant
All 106 H2ExecutionRepositoryTest tests pass! Let me also check the TriggerControllerTest:All 106 tests pass! Let me also check the TriggerControllerTest:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[find . -name "TriggerControllerTest.java" -path "/test/*" | head -5]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
All trigger tests pass. Let me also run the
BlueprintControllertests since it usesvalidateQueryFilters:Assistant
All blueprint controller tests pass. Now let me also check the TriggerRepository tests:Let me also check the TriggerRepository tests:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[./gradlew :jdbc-h2:test --tests "io.kestra.jdbc.repository.AbstractJdbcTriggerRepositoryTest" 2>&1 | tail -10]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
check for any other places that might need similar treatment:
Assistant
Let me check the
AbstractJdbcExecutionRepository.containsLeafForKindmethod - it's already recursive:Let me check thecontainsLeafForKindmethod inAbstractJdbcExecutionRepository- it's already recursive:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[sed -n '245,260p' jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcExecutionRepository.java]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>Assistant
Yes,
containsLeafForKindis already recursive. But I noticebuildDateFilterConditionmay have an issue with nested filters. Let me check more carefully:Assistant
Let me verify my fix works for the original issue scenario. Let me write a focused test that mimics the exact scenario from the issue:
Assistant
Both tests pass. Let me check the output to verify:
Assistant
Both tests pass. Let me clean up the test file:
Assistant
Now let me think about whether I need to update the issue more thoroughly. Let me check if there are any other places that may have the same bug.
Assistant
All tests pass. Now let me also make sure the changes don't affect the API description. Let me look at the diff and review:All tests pass. Now let me also make sure the changes don't affect the API description. Let me look at the diff and review:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[git diff --stat]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
Let me verify the diff and make sure the unused methods in DateUtils aren't causing any issues:
Assistant
The methods are still there but unused. They don't cause any issues, but they're dead code. Let me check if there are any compile warnings about unused private methods:
Assistant
There are
-Xlint:allenabled. Let me check if there are warnings about unused methods:Let me check if there are warnings about unused methods:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[timeout 120 ./gradlew :core:compileJava 2>&1 | grep -i "warning|unused" | head -20]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>Assistant
related to DateUtils. Let me also check the webserver compilation:
Assistant
No warnings about my changes. The compilation is clean. Let me verify all the changes one more time:No warnings about my changes. Let me verify all the changes one more time and run a final test:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[cat core/src/main/java/io/kestra/core/utils/DateUtils.java | grep -A 60 "public static void validateTimeline(List"]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
Let me clean up the unused methods since they're now dead code:
Assistant
The edit didn't work correctly. Let me restore and try again:Let me restore and try again with a different approach:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[git checkout core/src/main/java/io/kestra/core/utils/DateUtils.java sed -n '160,185p' core/src/main/java/io/kestra/core/utils/DateUtils.java]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
Good, the unused methods have been removed. Let me re-run the tests:
Assistant
All tests pass. Let me also verify by running a broader test to make sure the JDBC module still works:
Assistant
All tests pass. Let me check the final diff to make sure everything is clean:
Assistant
The diff looks good. Now let me also check the other files
Assistant
The diff looks good. Let me verify no test files are left behind:
Assistant
Only my changes are in the working tree. Let me do one final check by running all the related tests once more to make sure everything is working:Only my changes are in the working tree. Let me do one final check by running all the related tests once more to make sure everything is working:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[timeout 300 ./gradlew :core:test :webserver:test :jdbc-h2:test --tests "io.kestra.core.models.QueryFilterTest" --tests "io.kestra.webserver.utils.*" --tests "io.kestra.webserver.converters.QueryFilterFormatBinderTest" --tests "io.kestra.repository.h2.H2ExecutionRepositoryTest" --tests "io.kestra.repository.h2.H2TriggerRepositoryTest" 2>&1 | tail -15]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
All tests pass. Let me also run the JDBC tests to be safe.
Assistant
All tests pass. Let me now do one final verification by viewing the summary of the changes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.