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
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 the codebase and then try to reproduce the issue described.
The issue is about:
- HTTP 400 error when using conditional group filters
- The error message mentions "Field TIME_RANGE is not supported for resource EXECUTION"
- This happens in the Executions view when adding a conditional group filter
Let me start by exploring the repository structure.
Assistant
Let me explore the repository structure more to understand how it's organized.
Assistant
Let me search for the error message and files related to query filters.
Assistant
Let me examine the QueryFilter.java file, which seems to be the core model for query filters:
Assistant
Now let me look at the QueryFilterUtils.java file to understand how filters are processed:
Assistant
Now let me look at the ExecutionController and related files to understand how filters are validated:
Assistant
Now let me look at the
replaceTimeRangeWithComputedDateFiltermethod in theQueryFilterUtilsand see how it's called. The issue seems to be that when there's a conditional group filter (node with children), the TIME_RANGE filter might be nested inside the children and the replacement logic is only looking at the top-level filters.Let me look at how filters flow through the system:
Assistant
Now let me look at the
replaceTimeRangeWithComputedDateFilterfunction more closely. It processes filters at the top level, but doesn't recursively handle TIME_RANGE filters that may be nested inside a conditional group (node with children):Assistant
Let me look at the test file to understand the expected behavior:
Assistant
Now let me also check the
validateQueryFiltersfunction and how it handles nodes (conditional groups). I see the issue - when we have a conditional group with children, the TIME_RANGE filter might be passed to the validation for the EXECUTION resource, but EXECUTION doesn't support TIME_RANGE. The TIME_RANGE should be replaced with START_DATE before validation.Let me trace the flow more carefully:
Assistant
Now I can see the flow. At line 250, the
replaceTimeRangeWithComputedDateFilteris called before passing filters to the repository. But the issue is in how this function works. Let me look at theupdateFiltersmethod:Assistant
I see - the
updateFiltersmethod only looks at the top-level filters, not recursively into children of conditional group nodes. Now let me check theTimeLineSearch.extractFrommethod to see if it extracts the time range from nested filters:Assistant
Now I see the problem more clearly. The
TimeLineSearch.extractFrommethod iterates over filters, but if a filter is a node (conditional group), it checksfilter.field() == nulland skips it - it doesn't recursively process the children.Similarly,
updateFiltersonly processes top-level filters.Let me also look at the validation to understand the full flow:
Assistant
The validation in
collectValidationErrorscorrectly recursively validates children when it encounters a node. But the issue is that thereplaceTimeRangeWithComputedDateFilterfunction and related utility methods don't process TIME_RANGE filters when they are nested inside a conditional group (node with children).When a user creates a conditional group filter with a labels filter inside, the filter structure looks like:
{ "logical": "or", "children": [ { "field": "labels", "operation": "EQUALS", "value": "foo:bar" } ] }But the error message says "Field TIME_RANGE is not supported for resource EXECUTION". This means that somewhere, a TIME_RANGE filter is being added or passed through. Let me look at the test for the execution controller:
Assistant
command> grep -n "TIME_RANGE|conditional|children" /kestra/webserver/src/test/java/io/kestra/webserver/controllers/api/ExecutionControllerTest.java <tool_call> <function=bash_terminal> <parameter=command> grep -n "TIME_RANGE|conditional|children" /kestra/webserver/src/test/java/io/kestra/webserver/controllers/api/ExecutionControllerTest.java </tool_call>
Assistant
Let me try the grep command again properly.
Assistant
Let me look at the test file structure more carefully and find the tests related to QueryFilter validation.
Assistant
Assistant
Let me run the find command properly.
Assistant
Let me look at the QueryFilterFormatBinder to understand how filters are parsed from the request.
Assistant
Let me look at the test file for the binder to understand how conditional groups are structured:
Assistant
Looking at the test
shouldRemainBackwardCompatibleWithFlatLegacyFormat, I can see that TIME_RANGE is used at the top level. But the issue occurs when filters are nested inside conditional groups.Now I understand the issue:
TimeLineSearch.extractFromonly iterates over top-level filters and skips nodes (filters withfield() == null)updateFiltersonly maps over top-level filters and doesn't recursively process children
So if a TIME_RANGE filter is nested inside a conditional group (node), it won't be extracted or replaced, and validation will fail because TIME_RANGE is not in the EXECUTION resource's supported fields list.
Let me verify by checking the EXECUTION resource's supported fields:
Assistant
Now I understand the problem clearly.
TIME_RANGEis not in the supported fields for EXECUTION (or LOG, etc.). ThereplaceTimeRangeWithComputedDateFilterfunction is supposed to replace TIME_RANGE with START_DATE or END_DATE before validation, but it doesn't handle TIME_RANGE filters that are nested inside conditional groups (nodes with children).Now let me create a test script to reproduce the issue first.
Assistant
Now I understand the issue. Let me create a test script to reproduce the problem first.
Assistant
I need to fix two files:
TimeLineSearch.java- to recursively extract date filters from nested childrenQueryFilterUtils.java- to recursively update nested filters
Let me first open and edit
TimeLineSearch.java:Assistant
The open command needs to be called differently. Let me try again.
Assistant
I need to fix two files:
TimeLineSearch.java- to recursively extract date filters from nested childrenQueryFilterUtils.java- to recursively replace TIME_RANGE filters in nested children
Let me start with
TimeLineSearch.java:Assistant
Now I need to update
QueryFilterUtils.javato recursively replace TIME_RANGE filters in nested children. Let me view the file first.Assistant
Now I need to update
QueryFilterUtils.javato handle nested filters recursively. The key methods to update are:updateFilters- needs to recursively process children of nodesupdateFiltersForEndDate- samehasDateFiltercheck - needs to check nested filters toorewriteTriggerDateFilters- also needs recursive handling
Let me create the updated file:
Assistant
Let me verify the changes I made by looking at the files:
Assistant
Now let me run the existing tests to verify that my changes work correctly and don't break existing functionality:
Assistant
The tests seem to have compiled with warnings but I don't see the actual test results. Let me check if the tests passed.
Assistant
The tests show as UP-TO-DATE, which means Gradle didn't re-run them. Let me force a clean rebuild and run the tests again.
Assistant
The build is using cache. Let me force a rebuild by cleaning the cache and running the tests again.
Assistant
All 7 existing tests pass. Now let me also run the binder tests to make sure nothing is broken:
Assistant
All 15 binder tests pass. Now let me run the core QueryFilter tests to make sure nothing is broken there:
Assistant
All 730 tests pass. Now let me create a temporary test script to verify that my fix actually resolves the issue described - that conditional group filters with nested TIME_RANGE should now work correctly.
Assistant
Let me run more comprehensive tests to make sure nothing is broken:
Assistant
The full test suite is taking too long. Let me run a more targeted test to validate my changes work correctly. I'll look for tests related to execution controller or filter handling:
Assistant
The tests are passing. Let me verify the changes I made are correct and complete by reviewing the git diff.
Assistant
I need to run more tests to ensure my changes don't break any existing functionality, particularly tests related to the execution controller and log controller since they use the filter utilities.
Assistant
All 107 execution controller tests pass. Let me also run the LogController tests since they also use the filter utilities.
Assistant
All 27 LogController tests pass. Let me also run tests for trigger-related functionality since I also updated
rewriteTriggerDateFilters:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.