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
Now let me search for the relevant code related to filters and the error message we saw
Assistant
Let me see the complete file to understand the structure:
Assistant
me now check the issue more carefully and search for how filters are parsed and processed:
Assistant
me look at where the validation happens and where the issue arises:
Assistant
Let me look at the executions controller and see how filters are processed:
Assistant
me look at the QueryFilterFormat binder to see how the filters are parsed:
Assistant
Now I understand the issue clearly. The conditional group filters parse correctly into a tree structure with logical AND/OR operators and children. But the
QueryFilterUtils.updateFiltersmethod does not handle this case properly - it only deals with flat lists of leaf filters, treating the node (with logical + children) as if it were a leaf.Let me also look at the rest of the test cases:
Assistant
I have a clear understanding. Let me also look at the
validateQueryFiltersfunction more closely:Assistant
Now let me understand the flow. When a filter has a conditional group (logical=OR, children=[leaf1]), the flow is:
- The parser correctly creates the tree structure
replaceTimeRangeWithComputedDateFilteris called - this is where it fails because it doesn't recurse into the children
Let me trace through with
updateFilters:Assistant
Let me check the EXECUTION resource's supported fields more closely:
Assistant
me check the TimeLineSearch class:
Assistant
OK so the TimeLineSearch skips nodes (filters with null field). Good.
Now let me check the test to see if the flow is correct:
filters = [TIME_RANGE leaf, OR node with LABELS leaf]replaceTimeRangeWithComputedDateFilter:- TimeLineSearch.extractFrom: extracts timeRange from the leaf, returns resolved startDate
updateFilters(filters, resolvedStartDate):- hasDateFilter = true (because of TIME_RANGE leaf)
Assistant
Let me try this again.
Assistant
Now I see - the UI uses
encodeFilterGroupsToQuerywhich encodes filters usingfilters[or][N][field][OP]format.Now I need to figure out the actual flow. Let me check what
defaultQueryis and how it relates to TIMEAssistant
Let me check the topLogical default:
Assistant
Now I understand the issue. The fix is needed in
QueryFilterUtils.updateFiltersto recursively process children of nodes. Let me reproduce the issue first:Assistant
Let me check the existing tests to confirm the current behavior:
Assistant
Now let me check the current
replaceTimeRangeWithComputedDateFilterimplementation more carefully to understand the issue:Assistant
Now let me write a test that reproduces the issue:
Assistant
Let me check if I can quickly run the test directly with gradle:
Assistant
No compiled classes yet. Let me write a test inside the existing test file to confirm:
Assistant
Let me write a temporary test that reproduces the issue:
Assistant
I've reproduced the issue. The test failed because the TIME_RANGE filter nested inside a conditional group was NOT replaced with START_DATE.
Now let me also verify the actual error from validateQueryFilters:
Assistant
I've confirmed the bug. Now let me design and implement the fix.
Assistant
Let me also look at DateUtils.validateTimeline:
Assistant
Now let me look at the existing tests to ensure I understand what behaviors I should preserve:
Assistant
OK now I understand the test structure. Let me also look at the tests for
updateFiltersForEndDate:Assistant
Let me also look at how the validateQueryFilters function handles the nested case to ensure it's correct:
Assistant
Good - the validation already handles nested filters correctly (it recurses into children of nodes).
Now let me look at the JDBC repository implementation to see how it handles nested filters
Assistant
. Now let me check the LogController to see how it uses the same utility:
Assistant
Let me also look at where
rewriteTriggerDateFiltersis used:Assistant
Now I have a clear understanding of the bug. Let me implement the fix:
Assistant
Now let me implement the fix:
Assistant
Now I also need to fix
TimeLineSearch.extractFromto recurse into children:Assistant
Let me also fix
DateUtils.validateTimeline(List<QueryFilter>)to recurse:Assistant
Let me update DateUtils.java to handle nested filters:
Assistant
Let me use perl:
Assistant
Now let me run the reproduce test to confirm the fix works:
Assistant
There's a compilation error. Let me find it:
Assistant
fix the lambda capture issue:
Assistant
Let me also check the QueryFilterUtils.java for any compilation errors:
Assistant
Let me fix TimeLineSearch as well:
Assistant
Let me try compiling now:
Assistant
Both compile. Let me run the reproduce test:
Assistant
The fix works. Let me also run the existing tests for these files to ensure I haven't broken anything:
Assistant
All 22 tests pass. Let me also run the existing core tests for QueryFilterTest and DateUtilsTest:
Assistant
730 tests pass. Now let me extend my reproduction test to cover more edge cases to ensure the fix is robust:
Assistant
All 4 edge cases pass. Now let me also run the related tests in jdbc module:
Assistant
Let me also check that I haven't broken the integration with executions. Let me run the execution controller tests:
Assistant
All tests pass. Now let me also test the jdbc execution repository tests:
Assistant
The abstract test class isn't directly runnable. Let me check the H2 implementation:
Assistant
Now let me check the jdbc-h2 module tests:
Assistant
106 tests pass. Now let me also clean up my reproduce test (I'll remove it before submitting) and look at all the changes:
Assistant
me check the editorconfig:
Assistant
insert_final_newline=false`, let me revert that minor change:
Assistant
Good, no more trailing newline diff. Let me re-verify by checking:
Assistant
Now let me also check the final newline at the end of TimeLineSearch.java and remove if present:
Assistant
still a trailing newline. Let me remove it:
Assistant
Wait, the file has 3 lines ending with newline - the last 3 characters are "}\n\n}". Looking at the od output:
}\n\n}means "}\n\n" at the end. But there's no}\nat the end. Let me look at the file properly.Actually wait, I see now: the file content is
...}\n\n}where the last}has NO newline after it. So the file does NOT end with a newline. That's what we want.But the od output is showing 3 newlines in a row at the end. Let me check what's there.
Assistant
The file ends with
}(no trailing newline) which is what we want. Let me compare with the original:Assistant
Both end with the same bytes. Now let me re-check the diff is clean:
Assistant
Good, no newline diff. Let me also check the diff stat and verify everything is correct:
Assistant
Now let me also check the QueryFilterUtils final newline state:
Assistant
Same. Let me also check the DateUtils.java:
Assistant
All good. Now let me clean up the reproduce test (I'll delete it since I shouldn't add new tests):
Assistant
Now let me re-run the existing tests to ensure everything still works:
Assistant
All 45 tests pass. Let me also run the jdbc-h2 tests to ensure the repository tests still pass:
Assistant
All 106 H2 execution repository tests pass. Let me also test the LogController test:
Assistant
Let me now look at the LogController to verify how it uses these utilities and confirm everything works together:
Assistant
me also verify that the LOG resource supports TIME_RANGE (since the LogController also uses the same utility):
Assistant
me check who calls validateTimeline:
Assistant
Let me also verify the fix works correctly with the validateTimeline change:
Assistant
All 6 comprehensive tests pass. Let me clean up the comprehensive test (since I shouldn't add new tests):
Assistant
Now let me also check the LogController test to make sure my fix doesn't break anything related to logs:
Assistant
All LogController tests pass. Let me also test the TriggerController test:
Assistant
All 18 TriggerController tests pass. Let me also check the diff to make sure it's clean:
Assistant
Let me also run all the tests in webserver to make sure nothing else breaks:
Assistant
197 unit tests pass. Let me also run the core module tests:
Assistant
1698 core tests pass. Let me also run jdbc-h2 tests:
Assistant
There's one failing test. Let me investigate:
Assistant
is a trigger test, unrelated to our changes. Let me check if it's flaky:
Assistant
This test failure is about
flowTriggerAnyMode- it's about trigger ANY mode, not related to our changes. The error is:java.lang.RuntimeException: No execution for flow flow-trigger-any-mode-flow-listen exist in the databaseThis is likely a flaky test (timing-related, waiting for trigger to fire). Let me check if it's marked as flaky:Let me check if this test is flaky:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[grep -n "@Tag|@Flaky" core/src/test/java/io/kestra/core/runners/AbstractRunnerTest.java | head -5]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
me try again.
Assistant
Let me run the test in isolation to check if it's consistently failing:
Assistant
passes in isolation - it's a flaky test, not related to our changes. Let me verify this is pre-existing by checking with git:
Assistant
The test passes in isolation, so it's just a flaky test (timing-related), unrelated to our changes. Let me also run a broader set of relevant tests to make sure nothing else is broken:
Assistant
490 tests pass. Now let me also check the indexer tests:
Assistant
All JDBC tests pass. Now let me also run the executions tests to make sure nothing is broken:
Assistant
84 tests pass for ExecutionControllerRunnerTest. This is the most relevant test for the executions view since it includes tests for conditional group filters.
Let me check that the tests for conditional group filtering exist and pass:
Assistant
Assistant
The test passes. Let me clean it up:
Assistant
Now let me verify the final state of all my changes:
Assistant
Let me show the complete diff one more time:
Assistant
The diff looks clean and focused. Let me verify by listing the checklist items:
Checklist reasoning:
-
If an error was reported in the issue description, I have successfully reproduced it.
- I wrote a reproduction test (
ReproduceTest.java) that demonstrated the exact error: TIME_RANGE nested inside an OR node fails validation with "Field TIME_RANGE is not supported for resource EXECUTION".
- I wrote a reproduction test (
-
Assistant
Three files changed:
core/src/main/java/io/kestra/core/utils/DateUtils.java- validates timeline recursively into nested nodeswebserver/src/main/java/io/kestra/webserver/utils/QueryFilterUtils.java- rewrites TIME_RANGE/START_DATE/END_DATE recursively into nested nodes for both EXECUTION/LOG mode and TRIGGER modewebserver/src/main/java/io/kestra/webserver/utils/TimeLineSearch.java- extracts TIME_RANGE/START_DATE/END_DATE recursively into nested nodes
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.