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 identify the issue described. The issue is about HTTP 400 being returned when using conditional group filter queries, specifically related to
TIME_RANGEfield not being supported forEXECUTIONresource.Let me first explore the repository structure.
Assistant
Let me search for files related to the error message about TIME_RANGE and query filters.
Assistant
Let me look at the QueryFilter class and related files to understand the issue better.
<tool_call> <function=bash_terminal> <parameter=command> cat /kestra/core/src/main/java/io/kestra/core/models/QueryFilter.java </tool_call>
Assistant
Let me try again with the correct tool call format.
Assistant
Let me look at the QueryFilterUtils to understand how TIME_RANGE is handled:
Assistant
Let me look at the Execution controller to understand how filters are validated:
Assistant
Let me find the Execution controller to understand how the filters flow:
Assistant
Let me look at the ExecutionController to understand how it handles the validation:
Assistant
Let me look at the QueryFilterFormat annotation and its binder:
Assistant
The user is asking me to continue my work. Let me look at the QueryFilterFormat and QueryFilterFormatBinder to understand how validation happens for the filters.
Assistant
Now I need to understand the issue. The error message says: "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"
Looking at the code flow:
- The
QueryFilterFormatBinder.bind()method parses the query parameters and createsList<QueryFilter> - It does NOT validate the filters against the resource at this point
- The
Assistant
Let me try the cat command again.
Assistant
I can see the issue now. Let me trace the code flow:
- In
ExecutionController.searchExecutions(), filters are parsed then passed toQueryFilterUtils.replaceTimeRangeWithComputedDateFilter()which should convertTIME_RANGEtoSTART_DATE/END_DATE - Then
executionRepository.find()is called which callsAbstractJdbcRepository.filter()that validates filters
The problem is in
QueryFilterUtils.updateFilters()- it only processes top-level filters and doesn't recursively handleTIME_RANGEfilters nested inside conditional group nodes. Let me verify this:- In
Assistant
I found the issue! The
updateFilters()andupdateFiltersForEndDate()methods only process top-level filters in the list. When a conditional group node is added (withlogicalandchildren), anyTIME_RANGEfilters nested inside the children are NOT converted toSTART_DATE/END_DATE. So the validation fails becauseTIME_RANGEis not a supported field forEXECUTIONresource.Let me also check the
replaceTimeRangeWithComputedDateFiltermethod andTimeLineSearch.extractFromto see how they handle nested filters:Assistant
I see that
TimeLineSearch.extractFrom()only looks at top-level filters too. It doesn't recurse into children of node filters. But more importantly, theupdateFilters()method doesn't recursively process children of node filters either.Let me also look at existing tests to understand the expected behavior better:
Assistant
Now I understand the issue fully. The
updateFilters()method inQueryFilterUtils.javaonly processes top-level filters and doesn't recursively handle nestedTIME_RANGEfilters inside conditional group nodes. Let me look at the test to see how conditional groups are expected to work:Assistant
Now I understand the issue. Let me check if there's a test with conditional groups:
The issue is in
QueryFilterUtils.updateFilters()andQueryFilterUtils.updateFiltersForEndDate()- they don't recursively handle nested filters inside conditional group nodes. When a user adds a conditional group (a node withlogicalandchildren), anyTIME_RANGEfilters nested inside the children are NOT converted toSTART_DATE/END_DATE.Let me also check the
TimeLineSearch.extractFrom()method - it also doesn't handle nested filters.Let me look at the test file to see if there are tests for conditional groups:
Assistant
Good, now I see that there are tests with conditional group nodes. Let me also look at how the
TimeLineSearch.extractFrommethod handles these nodes and what the fix should look like.The issue is that:
TimeLineSearch.extractFrom()only looks at top-level filters, not nested childrenupdateFilters()andupdateFiltersForEndDate()only process top-level filters
The fix should be to make these methods recursive so they handle nested filters inside conditional group nodes.
Let me create a test script to reproduce the issue first:
Assistant
Now I understand the issue. The problem is that:
TimeLineSearch.extractFrom()only processes top-level filters and doesn't recursively look into children of conditional group nodesQueryFilterUtils.updateFilters()andQueryFilterUtils.updateFiltersForEndDate()only process top-level filters and don't recursively updateTIME_RANGEfilters nested inside conditional group nodes
So when a user adds a conditional group filter with a
TIME_RANGEfilter inside it, theTIME_RANGEfilter is not converted toSTART_DATE/END_DATE, and the validation fails becauseTIME_RANGEis not a supported field forEXECUTIONresource.Let me fix both
TimeLineSearch.javaandQueryFilterUtils.javato handle nested filters recursively.Assistant
The user hasn't responded yet - they just received my last action. Let me continue with the fix. I need to:
- Fix
TimeLineSearch.extractFrom()to recursively extract TIME_RANGE from nested children - Fix
QueryFilterUtils.updateFilters()andupdateFiltersForEndDate()to recursively process nested filters
Let me start by opening and editing the TimeLineSearch.java file.
- Fix
Assistant
Let me now apply the fix to the TimeLineSearch.java file. I'll use the edit command to replace the entire file content.
Assistant
Now let me fix the
QueryFilterUtils.javafile to recursively process nested filters inupdateFilters()andupdateFiltersForEndDate():Assistant
Now I need to fix
QueryFilterUtils.javato recursively handle nested filters inupdateFilters()andupdateFiltersForEndDate(). The key changes are:- Check for date filters recursively in children
- Update filters recursively for node filters
Assistant
Let me verify the changes were applied correctly and run the existing tests to make sure the fix works.
Assistant
The user hasn't said anything new - this is just the environment showing the current state. Let me continue with my work. I need to run the tests to verify my fix works correctly.
Assistant
The existing tests pass. Let me also run the TimeLineSearchTest to verify my changes to TimeLineSearch.java:
Assistant
Let me create a test script to verify the fix works for conditional groups with nested TIME_RANGE filters:
Assistant
Let me also run the core QueryFilter tests and some broader tests to ensure nothing is broken:
Assistant
All existing tests pass. Let me write a quick verification test to confirm the fix handles conditional groups with nested TIME_RANGE filters:
Assistant
The user's message is just showing the current state of the shell. Let me continue testing my fix by running a more comprehensive test. I should create a simple Java test that can be compiled and run with the project's test infrastructure to verify the fix works for conditional groups.
Let me run the ExecutionControllerTest to see if there are any related tests that might validate this fix.
Assistant
All tests pass. Let me verify my changes by viewing the diff:
Assistant
It seems my previous response had a formatting issue. Let me provide a clean summary and submit the changes.
Summary of Changes
The issue was that when a user adds a conditional group filter (with
logicalandchildren) containing aTIME_RANGEfilter, the backend returns HTTP 400 becauseTIME_RANGEis not a supported field for theEXECUTIONresource. TheTIME_RANGEfilter should be converted toSTART_DATEorEND_DATEbefore validation.Root Cause: The
TimeLineSearch.extractFrom()andQueryFilterUtils.updateFilters()methods only processed top-level filters and did not recursively handle nested filters inside conditional group nodes.Fix: Modified two files to recursively process nested filters:
-
TimeLineSearch.java: Added recursive method that traverses into node filters (conditional groups) to find nested , , and filters.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.