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.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /kestra, current file: none) bash-$
Assistant
No python available. I'll use the
edittool instead.Assistant
Good, file wasn't modified. Now let's use
open+editto insert helper methods after line 35.Assistant
Now let's insert the recursive helper methods after line 35, and update the three functions (updateFilters, updateFiltersForEndDate) to use recursion, plus rewriteTriggerDateFilters later.
Assistant
Now let's update
updateFiltersandupdateFiltersForEndDateto use the recursive helpers.Assistant
There's leftover duplicate closing lines 141-143. Let's remove them.
Assistant
Need blank line before
public static List<QueryFilter> replaceTimeRangeWithComputedStartDateFilter. Also updaterewriteTriggerDateFiltersto use recursive mapping.Assistant
Now let's fix
rewriteTriggerDateFiltersto use recursive mapping too.Assistant
Let's make this recursive as well.
Assistant
That's fine already - handles nested nodes properly for SQL generation. Now let's rebuild and re-run repro test (should now pass) plus run the full existing test suites.
Assistant
The fix resolves the reported issue. Now let's remove the temp test and run the existing full test suites for the affected files.
Assistant
All existing tests pass. Now let's run DateUtils related tests in core module.
Assistant
Let's compile core module to make sure DateUtils change is valid.
Assistant
Good, compiles fine. Now let's run the broader test suites that matter: QueryFilterTest in core, jdbc AbstractExecutionRepositoryTest (nested groups), and webserver ExecutionControllerTest for filters.
Assistant
All 730 pass. Now let's run the ExecutionControllerTest for filters (likely requires DB, might be slow but let's try just filter-related tests).
Assistant
All pass. Now let's run jdbc AbstractExecutionRepositoryTest (contains OR/AND group tests) as h2 implementation.
Assistant
All 106 tests pass, including complex nested filter tests. Let's also run the full webserver test suite to be thorough (or at least utils-related), and the jdbc core test suite for DateUtils, plus core full test suite once more for confidence.
Assistant
Good, all pass. Let's also check final diff and clean up.
Assistant
Let's view the full diff for a final review.
Assistant
This looks good. Now let's clean up remaining temp files and verify no stray test files remain.
Assistant
Clean. Now let's also double check TriggerController's rewriteTriggerDateFilters usage still works with nested groups (compile jdbc tests for triggers, since TRIGGER also supports nested filters potentially).
Assistant
All good. Let's also run flow and log H2 repository tests, since they also use
replaceTimeRangeWithComputedDateFilter-like paths (Flow doesn't necessarily use it, but let's check LogController flow).Assistant
All 297 tests pass. Now let's do a final review of the full diff and ensure everything is clean.
Assistant
Everything is clean and ready. Let me go through the checklist:
Assistant
Summary
Root cause: When a
TIME_RANGEquery filter is nested inside an AND/OR conditional group (e.g.filters[or][0][timeRange][EQUALS]=PT168H), the backend's TIME_RANGE→START_DATE/END_DATE conversion logic (QueryFilterUtils.updateFilters/updateFiltersForEndDate,TimeLineSearch.extractFrom) only inspected the top-level filter list, never recursing into thechildrenof node filters. SinceResource.EXECUTION(and other resources) intentionally do not listTIME_RANGEas a supported field (because it's expected to always be converted before validation/repository access), aTIME_RANGEleaf trapped inside a nested group survived unconverted and failedQueryFilter.validateQueryFilterswith "Field TIME_RANGE is not supported for resource EXECUTION."Fix: Made the filter-tree traversal recursive in three places so nested TIME_RANGE/START_DATE/END_DATE filters (at any depth inside AND/OR conditional groups) are properly located and converted:
webserver/.../QueryFilterUtils.java: added genericanyMatchInTree/mapFilterTreehelpers and used them inupdateFilters,updateFiltersForEndDate, andrewriteTriggerDateFilters.webserver/.../TimeLineSearch.java:extractFromnow recursively walks node children to find START_DATE/END_DATE/TIME_RANGE.core/.../DateUtils.java:validateTimeline(List<QueryFilter>)now recursively collects START_DATE/END_DATE bounds from nested filters too.
Checklist
- Reproduced the error: Yes — wrote a temporary JUnit test exercising
QueryFilterFormatBinder→QueryFilterUtils.replaceTimeRangeWithComputedStartDateFilter→QueryFilter.validateQueryFilterswith aTIME_RANGEfilter nested inside anORgroup targetingResource.EXECUTION, and it failed with the exact reported error message. - Confirmed the fix resolves it: Yes — after the fix, the same reproduction test passes, and I verified the nested
TIME_RANGEfilter is actually rewritten into aSTART_DATEfilter inside the group (not just silently ignored). - Edge cases considered: Handled arbitrarily deep/nested AND/OR groups, multiple resource types (EXECUTION, TRIGGER via
rewriteTriggerDateFilters, LOG, FLOW), thedateFilter=END_DATE/START_OR_END_DATEvariants, the "no date filter present anywhere" default-injection behavior (still only added once, respecting nested filters as satisfying the requirement), and the mutual-exclusivity check between timeRange and startDate/endDate (now also honored across nested filters). - Ran existing tests: Ran
core:test(730 tests, all pass, includingQueryFilterTest),webserver:testforQueryFilterUtilsTest,TimeLineSearchTest,QueryFilterFormatBinderTest,ExecutionControllerTest,DashboardControllerTest,MetricControllerTest(all pass), andjdbc-h2:testforH2ExecutionRepositoryTest(106 tests incl. complex nested AND/OR filter cases),H2TriggerRepositoryTest(151 tests),H2LogRepositoryTest/H2FlowRepositoryTest(297 tests) — all pass. Temporary reproduction test files were removed before submission.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →