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 understanding the issue. The problem is that when using conditional group filters in the Executions view, the backend returns an HTTP 400 error. The error message indicates that "Field TIME_RANGE is not supported for resource EXECUTION."
This suggests that when a conditional group filter is created, it's incorrectly including a TIME_RANGE field that shouldn't be there for execution queries.
Let me first explore the repository structure to understand the codebase.
Assistant
Let me explore the repository structure more systematically and look for files related to filters and query execution.
Assistant
Let me search for files related to filters, query filters, and TIME_RANGE to understand the issue.
Assistant
Now let me look at the QueryFilter.java file to understand the structure of filters.
Assistant
Now I can see the QueryFilter structure. Let me look at the QueryFilterUtils.java which is likely where the validation happens:
Assistant
Now let me search for where the validation happens with the error message mentioned in the issue:
Assistant
Let me look at the ExecutionController to understand how it handles queries and where the validation happens:
Assistant
Now let me look at the QueryFilterFormat and QueryFilterFormatBinder which is responsible for parsing the filters:
Assistant
Now I understand the structure. Let me look at where the validation happens. The error message says "Field TIME_RANGE is not supported for resource EXECUTION" - this means when a conditional group filter is used, the TIME_RANGE field is being validated but EXECUTION resource doesn't support TIME_RANGE. Let me check the EXECUTION resource's supported fields:
Assistant
I see! The
EXECUTIONresource doesn't includeTIME_RANGEin its supported fields. However, theTIME_RANGEfield is supposed to be transformed byQueryFilterUtils.replaceTimeRangeWithComputedDateFilter()before validation. But the issue is that the validation happens before this transformation in some cases.Let me check where the validation is called:
Assistant
Let me check the
AbstractJdbcRepository.javato understand when validation happens:Assistant
Now I see where the validation happens - in the
filtermethod at line 252. The validation happens after the controller callsreplaceTimeRangeWithComputedDateFilter(), so TIME_RANGE should already be replaced. But the issue is that the validation happens in the repository layer, and the transformation happens in the controller layer.Let me check the
Searchableutility class and understand the full flow:Assistant
Now let me understand the flow better. I need to look at the test file to understand how the validation is performed with conditional groups:
Assistant
Let me look at the test file for QueryFilter to understand the validation logic:
Assistant
Now let me look at the test that checks node (conditional group) validation:
Assistant
Now let me look at the test for QueryFilterFormatBinder which handles the conditional groups:
Assistant
Now let me look at the ExecutionControllerTest to see if there are tests for conditional groups:
Assistant
Let me look at the TimeLineSearch class to understand how TIME_RANGE is extracted:
Assistant
Now I can see the issue! The
TimeLineSearch.extractFrom()method only extractsTIME_RANGE,START_DATE, andEND_DATEfrom the top-level filters. It doesn't recurse into the children of node (conditional group) filters.When a conditional group filter is created with children like
labels, theTIME_RANGEfilter might still be present in the list but NOT replaced because:TimeLineSearch.extractFrom()only looks at top-level filtersQueryFilterUtils.replaceTimeRangeWithComputedDateFilter()only replaces top-levelTIME_RANGEfilters- When validation happens, if there's a
TIME_RANGEfilter nested inside a conditional group (like a default one), it will fail validation becauseEXECUTIONresource doesn't supportTIME_RANGE.
But wait, let me re-read the issue. The issue says when a user adds a conditional group and adds a label filter like
foo:bar, then it fails with TIME_RANGE error. This suggests that there might be a default TIME_RANGE filter that's being kept.Let me look at how the replacement is done more carefully:
Assistant
I see the issue now. Let me look at the
updateFiltersmethod more carefully:Assistant
Let me understand the issue better by looking at the tests and how the validation flows through the system:
Assistant
command> cat /kestra/webserver/src/test/java/io/kestra/webserver/utils/QueryFilterUtilsTest.java </tool_call>
Assistant
I need to properly format my tool call.
Assistant
Assistant
Let me properly format the command.
Assistant
Let me understand the issue better by looking at how validation works and where TIME_RANGE might remain after processing:
Assistant
Let me look at the
updateFiltersmethod to confirm it doesn't handle nested TIME_RANGE filters:Assistant
Assistant
Let me continue investigating the issue by looking for validation happening at the binder level or other entry points.
Assistant
Now I understand the issue better. Let me look at the flow when conditional groups are used. The problem is that
updateFilters()andTimeLineSearch.extractFrom()don't recurse into node children, so if a TIME_RANGE filter is nested inside a conditional group, it won't be found or replaced.Let me first create a test script to reproduce the issue:
Assistant
Let me trace through the code more carefully. I need to understand what happens when a conditional group is added. Let me check how the filters are processed when there's a node (conditional group) in the list.
Assistant
Let me check if the binder performs any validation:
Assistant
Now I understand the issue! Let me trace through a scenario where this fails. When a conditional group (node) contains a TIME_RANGE filter, the
TimeLineSearch.extractFrom()andupdateFilters()methods don't recurse into node children, so nested TIME_RANGE filters won't be found or replaced.Let me look at the test for conditional groups to understand the structure better:
Assistant
The command failed, but there's no error message shown. Let me try a simpler grep command.
Assistant
Now I understand the issue. The
TimeLineSearch.extractFrom()andupdateFilters()methods inQueryFilterUtils.javadon't recurse into node children (conditional groups). So when aTIME_RANGEfilter is inside a conditional group, it won't be extracted or replaced, and validation will fail.Let me write a simple test script to reproduce this issue:
Assistant
Looking at the issue, I can see that when a conditional group (node) is used with filters, the TIME_RANGE filter might be nested inside the conditional group, but
TimeLineSearch.extractFrom()andupdateFilters()only process top-level filters. Let me verify this by examining the code flow more carefully.Assistant
This confirms my hypothesis. Neither
TimeLineSearch.extractFrom()norQueryFilterUtils.updateFilters()handle node filters (conditional groups) - they only process top-level leaf filters.Now let me understand the exact bug. When the UI sends a conditional group filter, the TIME_RANGE filter might be at the top level, but let me check if there's a scenario where TIME_RANGE ends up inside a node.
Assistant
Now I fully understand the issue. When a conditional group (node) is used,
TimeLineSearch.extractFrom()andupdateFilters()don't recurse into the node's children. So if a TIME_RANGE filter is inside a conditional group, it won't be extracted or replaced, causing validation to fail.The fix needs to make both methods recurse into node children. Let me implement the fix:
Assistant
Now I understand the issue. When a conditional group (node) is added, the
TimeLineSearch.extractFrom()andQueryFilterUtils.updateFilters()methods don't recurse into node children. If a TIME_RANGE filter is inside a conditional group, it won't be extracted or replaced, causing validation to fail.Let me fix both files:
Assistant
I need to fix both
TimeLineSearch.extractFrom()andQueryFilterUtils.updateFilters()to recurse into node children (conditional groups) so that TIME_RANGE filters inside conditional groups are properly extracted and replaced.Let me start by fixing
TimeLineSearch.java:Assistant
Now let me also update the
QueryFilterUtils.javato properly recurse into node children when replacing TIME_RANGE filters:Assistant
Now let me run the existing tests to verify my changes work correctly:
Assistant
Let me find the correct project name:
Assistant
The existing tests passed. Now let me also run the TimeLineSearchTest to make sure my changes to TimeLineSearch.java work correctly.
Assistant
All tests passed. Now let me also run the QueryFilterFormatBinderTest to make sure the filter binding still works correctly:
Assistant
All related tests pass. Now let me run more comprehensive tests to ensure I haven't broken anything else:
Assistant
All tests pass. Let me also run the Searchable tests to ensure nothing is broken there:
Assistant
All tests pass. Now let me write a simple test script to verify that my fix handles the specific scenario described in the issue (TIME_RANGE filter inside a conditional group):
Assistant
I need to write a simpler test to verify my fix works. Let me look at what tests already exist and run them to confirm the fix is working. Let me also look at the jdbc repository tests since that's where the validation happens.
Assistant
Now let me verify my fix handles the specific issue case by examining the diff of my changes and making sure the logic is correct:
Assistant
I see there's a bug in my TimeLineSearch.java fix - I'm calling
extractFromFiltertwice in the loop, but the first call discards the result. Let me fix this:Assistant
Now let me run a broader set of tests related to query filters to make sure I haven't broken anything:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.