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 start by exploring the repository structure to understand the codebase and then locate the relevant code for this issue.
Assistant
Let me search for files related to filters and the error message.
Assistant
Good, I found the relevant file. Let me look at the QueryFilter.java file first.
Assistant
Let me look at the REST controller or service that handles these filters:
Assistant
Let me check the AbstractJdbcRepository to see how filters are used.
Assistant
This is key - CHILD_FILTER is a field that's supported in the repository but let me understand the issue better. The problem seems to be related to conditional groups (AND/OR nodes with children filters). Let me look at how filters are validated and used.
Assistant
Now let me look at the AbstractJdbcRepository to see how it processes the filters:
<tool_call> <function=bash_terminal> <parameter=command> grep -A 50 "CHILD_FILTER" /kestra/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcRepository.java | head -100 </tool_call>
Assistant
Let me look at the AbstractJdbcRepository file to understand how it handles filters.
Assistant
Let me read the relevant parts of AbstractJdbcRepository to understand how filters are processed.
Assistant
Let me search for where TIME_RANGE is being used or set:
Assistant
Let me look at the QueryFilterUtils to understand how TIME_RANGE is handled:
Assistant
Let me look at the TimeLineSearch class to understand how it extracts TIME_RANGE from filters:
Assistant
Now I understand the issue. Let me check where TimeLineSearch.extractFrom is called and how filters are processed:
Assistant
Now I understand the issue! The problem is in
TimeLineSearch.extractFrom()and the filter replacement logic. These methods only iterate over top-level filters, not recursively into conditional groups (AND/OR nodes with children). Let me check how filters are used:Assistant
Let me check the test files to understand the expected behavior better:
Assistant
Now I understand the issue. The problem is that
TimeLineSearch.extractFrom()and the filter replacement methods only work with top-level filters, not recursively into conditional groups (AND/OR nodes with children). When a conditional group contains a TIME_RANGE filter in its children, it's not being found and replaced, so the TIME_RANGE filter reaches validation and fails because EXECUTION doesn't support TIME_RANGE at the top level.Let me look at how filters are sent to the API:
Assistant
Let me look at how the filters are processed in the ExecutionController.
Assistant
Let me look at the test to understand the expected behavior better:
Assistant
Now I understand the issue. Let me create a test to reproduce it:
Assistant
Let me look more carefully at the TimeLineSearch.extractFrom method to understand the issue:
Assistant
Now I understand the issue completely. The problem is that:
TimeLineSearch.extractFrom()only iterates over top-level filters, not recursively into conditional groups (AND/OR nodes with children).QueryFilterUtils.updateFilters()and related methods also only work with top-level filters.- When a TIME_RANGE filter is nested inside a conditional group, it's not found and replaced with START_DATE.
- TIME_RANGE is not supported for EXECUTION resource, so validation fails with HTTP 400.
Let me create helper methods to recursively handle filters. First, let me look at the full picture of what needs to be fixed:
Assistant
Now I understand the issue clearly. The problem is that:
TimeLineSearch.extractFrom()only iterates over top-level filters, not recursively into conditional groups (AND/OR nodes with children).QueryFilterUtils.updateFilters()and related methods also only work with top-level filters.- When a TIME_RANGE filter is nested inside a conditional group, it's not found and replaced with START_DATE.
- TIME_RANGE is not supported for EXECUTION resource, so validation fails.
I need to make these methods handle nested conditional groups recursively. Let me fix the code:
Assistant
Let me look at the QueryFilter structure again:
Assistant
Now I understand the structure better. Let me fix the issue by modifying the
TimeLineSearch.javaandQueryFilterUtils.javato recursively handle conditional groups.Assistant
I'll fix the issue by modifying the
TimeLineSearch.javaandQueryFilterUtils.javato recursively handle conditional groups.Let me start by fixing
TimeLineSearch.java:Assistant
Let me check the current state and use a different approach:
Assistant
I need to use the
opencommand without arguments to open the file, or use the file path properly.Assistant
Let me write the complete file instead:
Assistant
Now I need to update
QueryFilterUtils.javato recursively handle filters in conditional groups. Let me first understand which methods need updating:Assistant
Good! Now let me verify the changes and test them:
Assistant
Now let me check the existing tests to understand what they expect:
Assistant
Let me run the existing tests to make sure my changes don't break them:
Assistant
Great! The tests are passing. Let me also run the QueryFilterUtilsTest:
Assistant
Excellent! All existing tests pass. Now let me write a test to verify the fix works for conditional groups:
Assistant
Let me create a simple test script to verify the fix works.
Assistant
Now let me run the test to verify the fix works.
Assistant
I see the issue. The problem is that when we have multiple TIME_RANGE filters at different levels, the code is trying to set both startDate and timeRange, which is mutually exclusive. Let me fix the logic:
Assistant
Now let me run the tests again:
Assistant
I see the issue now. When we recursively extract from children, the default startDate is being set in the child result, and then when we return to the parent, if the parent also has a TIME_RANGE, we have both startDate and timeRange set, which is invalid.
The fix should be to not apply the default startDate in recursive calls if we're going to use it in the parent. Instead, we should only apply defaults at the top level.
Assistant
Now let me run the tests again to see if this fix works.
Assistant
All new tests pass. Now let me run the existing tests to make sure the fix doesn't break anything:
Assistant
Excellent! All tests pass. Let me run a broader set of tests to make sure the changes work correctly across the board:
Assistant
All tests pass. Let me clean up the test file I created and run some broader tests to ensure everything works:
Assistant
Let me run a broader set of tests to verify the fix doesn't break anything:
Assistant
All tests pass. Let me now verify my changes and document what was done:
Assistant
Let me verify the changes are correct by viewing the final state of the modified files:
Assistant
Let me check the git diff to see the actual changes made:
Assistant
Let me check the git diff to confirm the changes:
Assistant
The changes look correct. Now let me run broader tests to ensure nothing is broken:
Assistant
All tests pass. Let me summarize the changes I made to fix the issue.
Summary of Changes
Problem
The backend returned HTTP 400 when users added a conditional group (AND/OR) containing a TIME_RANGE filter. This happened because the
TimeLineSearch.extractFrom()method andQueryFilterUtilsmethods only worked with top-level filters and did not recursively search within conditional groups.Since TIME_RANGE is not supported for EXECUTION resources, validation would fail with the error:
Field TIME_RANGE is not supported for resource EXECUTION.
Solution
I modified two files to recursively handle filters within conditional groups:
1.
TimeLineSearch.java- Added
extractFromRecursive()method that recursively searches nested filters within conditional groups (AND/OR nodes)
- Added
Assistant
Now let me verify one more time that all the tests pass before submitting.
Assistant
Let me verify the tests pass by running the full test output.
Assistant
All tests pass successfully. The fix is complete. Let me provide the final summary:
Fix Summary
Issue: Backend returned HTTP 400 when users added a conditional group (AND/OR) containing a TIME_RANGE filter. The error message indicated that TIME_RANGE is not supported for EXECUTION resource.
Root Cause: The
TimeLineSearch.extractFrom()andQueryFilterUtilsmethods only processed top-level filters and did not recursively search within conditional groups (AND/OR nodes with children). When a TIME_RANGE filter was nested inside a conditional group, it wasn't found and replaced with START_DATE, causing validation to fail.Solution: Modified two files to recursively handle filters within conditional groups:
-
TimeLineSearch.java: AddedextractFromRecursive()method to recursively search nested filters within conditional groups. Only applies defaults at the top level. -
QueryFilterUtils.java: AddedanyMatchRecursive()and helper methods, and updated , , and to use these recursive methods.
-
Assistant
Let me try the submit command again.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.