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.
Assistant
The
collectValidationErrorsmethod handles nodes (conditional groups) by recursing into children. But the error message says "Field TIME_RANGE is not supported for resource EXECUTION". So the issue is that a TIME_RANGE field is being sent. Let me look at the EXECUTION resource to see if TIME_RANGE is supported.Let me look at the EXECUTION resource definition.
Assistant
The EXECUTION resource doesn't support TIME_RANGE. The error message says "Field TIME_RANGE is not supported for resource EXECUTION". This means when a conditional group is added, the UI is sending a TIME_RANGE field.
Wait, let me re-read the issue. The issue is about conditional groups. When you add a conditional group (a node with logical OR and children), the backend should accept it. The error says TIME_RANGE is not supported.
Let me look at the frontend code to understand how filters are sent. Actually, let me look more carefully at the validation logic. The
collectValidationErrorsrecurses into children for nodes. So why is TIME_RANGE being checked against EXECUTION?Let me look at the QueryFilterUtils and the converters.
Assistant
So
replaceTimeRangeWithComputedDateFilterprocesses TIME_RANGE filters. The issue is that this method processes the top-level list of filters, but doesn't recurse into conditional groups (nodes). The TIME_RANGE filter might be present at the top level, andreplaceTimeRangeWithComputedDateFilterhandles it. But the validation happens at a different stage.Wait, let me look at where
validateQueryFiltersis called and wherereplaceTimeRangeWithComputedDateFilteris called. The order matters. If validation happens BEFORE the TIME_RANGE replacement, then the TIME_RANGE field would fail validation against EXECUTION resource because TIME_RANGE is not in the EXECUTION supported fields.Let me search for where these are called.
Assistant
So in the ExecutionController, the
replaceTimeRangeWithComputedDateFilteris called, then passed toexecutionRepository.find. The validationvalidateQueryFiltersis called inAbstractJdbcRepository. Let me look at that.Assistant
So the order in ExecutionController.searchExecutions:
replaceTimeRangeWithComputedDateFilter(filters, dateFilter)- this processes TIME_RANGE at the top level only, not in conditional groups.executionRepository.find(...)which callsfilter()which callsvalidateQueryFilters(filters, resource).
So the issue: when a conditional group (node with children) is sent, and one of the children is a TIME_RANGE filter, the
replaceTimeRangeWithComputedDateFilterdoesn't recurse into the children. So the TIME_RANGE remains in the children, and when is called, it recurses into the children and finds TIME_RANGE which is not supported for EXECUTION.Assistant
So
TimeLineSearch.extractFromiterates over the top-level filters. If a filter is a node (conditional group),filter.field()is null, so it's skipped viaif (filter.field() == null) continue;. So the conditional group children are not processed for TIME_RANGE extraction.Now, the issue: The default filter set for Executions view includes TIME_RANGE. When you add a conditional group, the structure might be:
- TIME_RANGE (leaf at top level)
- OR node with children: [LABELS foo:bar]
In this case,
replaceTimeRangeWithComputedDateFiltershould:TimeLineSearch.extractFrom(filters)- finds TIME_RANGE at top level, computes startDate.updateFilters(filters, resolvedDate)- maps each filter: if it's a TIME_RANGE or START_DATE, replace with START_DATE; else keep. The OR node is not a TIME_RANGE/START_DATE, so it's kept as is.
So after this, the TIME_RANGE at top level should be replaced with START_DATE. The OR node children (LABELS) are kept. Then validation should pass because START_DATE and LABELS are supported.
Assistant
Let me look for where the filters are sent in the Executions view. Let me look at the filter composable.
Assistant
Let me search for where filters with "children" or "logical" are constructed in the UI. The issue is about conditional groups. Let me search more broadly.
Assistant
Let me look for the FilterInputs component which handles the conditional groups. Let me search for the filter UI components that handle groups.
Assistant
Let me look at the useFilters composable and how filters are managed. Let me look at the
useFilters.tscomposable.Assistant
Let me look at the Executions.vue and the date-select. Let me find the FilterBar component that handles conditional groups. Let me search for "FilterInputs" or the design system filter component.
Assistant
Let me search for where filters are sent to the backend in the executions store.
Assistant
No "logical" in the UI. Let me search for "node" or how the conditional group is represented. The issue mentions "conditional group". Let me look at the design system Filter component. Let me search for the filter input component.
Assistant
Assistant
Now I understand the structure. The binder parses URL params into a tree of QueryFilter. Conditional groups are nodes with
logicalandchildren.Now let me trace what happens with the Executions view. The TIME_RANGE is a top-level filter. When you add a conditional group, the URL might look like:
filters[timeRange][EQUALS]=PT168H filters[or][0][labels][EQUALS][foo]=barSo the binder produces:
- TIME_RANGE leaf (top-level)
- OR node with children: [LABELS leaf]
Then
replaceTimeRangeWithComputedDateFilterprocesses:TimeLineSearch.extractFrom(filters)- finds TIME_RANGE at top level. node skipped. startDate = now - PT168H.
Assistant
Assistant
Now let me think about the scenario. The TIME_RANGE is at top level. When there's a conditional group, the top-level list contains [TIME_RANGE, OR[LABELS]]. The
replaceTimeRangeWithComputedDateFilterproduces [START_DATE, OR[LABELS]]. Then validation passes.Wait, but
validateTimeline(updatedFilters)is called at the end ofreplaceTimeRangeWithComputedDateFilter. Let me checkDateUtils.validateTimeline.Assistant
OK so validateTimeline iterates over top-level filters and checks isStartDateFilter/isEndDateFilter. For a node,
filter.field()would be null. Let me check isStartDateFilter.Assistant
OK so validateTimeline would NPE if
filter.field()is null? No,QueryFilter.Field.END_DATE.equals(filter.field())- END_DATE.equals(null) returns false, so safe.So the flow with [TIME_RANGE, OR[LABELS]] produces [START_DATE, OR[LABELS]] and validation passes.
Hmm. So the error must come from a different scenario. Let me reconsider. Maybe the issue is that the TIME_RANGE filter is INSIDE the conditional group. Let me look at how the UI builds the request.
Actually, let me look at the Executions.vue and the date-select, and how the timeRange is added. Let me look at how filters are assembled and sent.
Assistant
Hmm, so the Executions.vue doesn't use
filters[timeRange]directly. Let me look at the KsFilter component and how it builds the query. The timeRange is probably added via the design system filter. Let me look at the Executions.vue more thoroughly and the date-select component.Assistant
Let me look at how the timeRange is added to the query in Executions.vue (the loadData function and the filters construction).
Assistant
Let me look at the loadData function and how the timeRange is added. Let me search for "selectedTimeRange" and "timeRange" usage.
Assistant
Let me look at the loadData function. The filters come from route.query which includes the decoded filters. The KSFilter component encodes filters into the URL query. Let me look at the loadData function.
Assistant
The
loadQuerymerges the route query filters into the base. The KSFilter component encodes the filters (including the timeRange and conditional groups) into the route query. Let me look at how KSFilter encodes filters and how the design system encodes conditional groups and timeRange into the URL. Let me look at the design system's encode/decode functions.Assistant
Assistant
Assistant
So
errorFilterCombinationsincludesTIME_RANGEas a top-level filter that should fail (because it's not processed through replaceTimeRange before find). This test directly passes TIME_RANGE to and expects InvalidQueryFiltersException. So validation rejects TIME_RANGE at the repository level.Assistant
Assistant
So
normalizeRouteTimeRangeFilterwritesfilters[timeRange][EQUALS]=valueat the TOP level (not wrapped). So when the user changes the time range via QuickFilters, it writesfilters[timeRange][EQUALS]=PT168Hat the top level.But when the user adds a conditional group, the
encodeFilterGroupsToQueryre-encodes ALL filters including the timeRange. Wait, but how does the timeRange get into the filter groups? Let me look at useFilters.ts in design system.Actually, the route query has
filters[timeRange][EQUALS]=PT168H(top-level, from QuickFilters). When the KsFilter re-encodes the groups, does it include the timeRange? Let me look at how the groups are built from the route and how timeRange is included.Let me look at routeDecoder.ts and useFilters.ts.
Assistant
Assistant
So TIME_RANGE is not handled in
getConditionOnField. It would fall through to the generic handler. Let me check what the generic handler does (the fallback at the end).Assistant
Interesting. There IS a
timeRangeConditionhandler for TIME_RANGE ingetConditionOnField. Let me look at it.Assistant
So
timeRangeConditionthrows "Unsupported field: TIME_RANGE". So even if validation passed, the TIME_RANGE filter reaching the repository would throw. So the TIME_RANGE must be resolved before reaching the repository (which is whatreplaceTimeRangeWithComputedDateFilterdoes, but only at top level).So if a TIME_RANGE is inside a conditional group and reaches the repository, it would throw "Unsupported field: TIME_RANGE" (after validation, if we removed TIME_RANGE from validation... no, validation rejects it first).
So the fix must resolve TIME_RANGE inside conditional groups before the repository call. The is the place.
Assistant
Let me write a reproduction test. I'll create a temporary test that:
- Builds a filter tree: [OR[TIME_RANGE, OR[LABELS]]] (the wrapped scenario).
- Calls replaceTimeRangeWithComputedDateFilter.
- Calls validateQueryFilters and checks it throws.
Let me create the test file.
Assistant
Assistant
So the LogController also calls
replaceTimeRangeWithComputedStartDateFilter. My fix in QueryFilterUtils covers both.Now let me also check: the LogController
buildExecutionFilters— does it wrap? Let me check. Actually, the mainfindendpoint usesreplaceTimeRangeWithComputedStartDateFilterwhich my fix covers.Now let me implement the fix. Let me start with
TimeLineSearch.extractFrom.Let me view the current file again and rewrite it.
Assistant
Now let me rewrite
extractFromto recurse into nodes. I'll add a recursive helper that walks the tree and collects date parts into a mutable holder.Assistant
Now let me update QueryFilterUtils to make
updateFilters,updateFiltersForEndDate, andrewriteTriggerDateFiltersrecursive. Let me view the file once more and edit it.Assistant
Now let me make the edits. I'll add a
mapTreerecursive helper and recursivehasDateFilter/hasDateBoundaryhelpers, then updateupdateFilters,updateFiltersForEndDate,rewriteTriggerDateFiltersto use recursion.Let me first add the import for
java.util.function.UnaryOperator.Assistant
Now let me update
updateFiltersto be recursive. Let me replace lines 63-81.Assistant
Now let me update
updateFiltersForEndDate(lines 85-101) to be recursive.Assistant
Now let me update
rewriteTriggerDateFiltersto be recursive.Assistant
Oops, there are leftover duplicate lines 171-172 from the original block. Let me fix that.
Assistant
Now I need to add the
mapTree,hasStartDateOrTimeRange, andhasDateBoundaryhelper methods. Let me add them afterisDateBoundaryFilter(line 36).Assistant
Now let me verify the full file compiles and the reproduction test passes. Let me run the repro test.
Assistant
The reproduction test now passes. The TIME_RANGE inside the conditional group is resolved to START_DATE and validation passes.
Now let me also reproduce using the actual URL → binder flow to ensure the full path works end-to-end. Let me update my repro test to use the binder parsing the actual URL params (simulating the UI).
Assistant
There's a compilation error. Let me see the actual error.
Assistant
The
getQueryFilters(Map)is package-private. My test is in a different package. Let me place the URL-based test in the converters package to verify the full binder flow.Assistant
Both tests pass. The full URL flow (binder → replaceTimeRange → validate) now works.
Now let me make sure I haven't broken existing tests. Let me run the existing tests for QueryFilterUtils, QueryFilterFormatBinder, TimeLineSearch.
Assistant
All existing tests pass. Let me look at the TimeLineSearchTest to understand what's tested there.
Assistant
All those tests pass. Now let me run the JDBC repository tests that exercise the conditional groups and the filter building.
Assistant
This test doesn't test conditional groups directly. Let me check if there's an ExecutionControllerTest that exercises the full search flow with filters.
Assistant
Let me look at the search test setup to understand whether running the full controller test is feasible.
Assistant
The
badQueryFilterstest asserts the exact error message. My change doesn't affect this. Let me run this test plus check the test infrastructure to run an integration test confirming conditional groups work end-to-end.Assistant
This is a
@KestraTestwhich boots the full app with H2 in-memory. Let me run thebadQueryFilterstest to confirm I didn't break the error path, and also write a temporary end-to-end integration test to confirm the HTTP 400 is resolved. First, let me look at an existing search test that seeds executions to model my integration test on it.Assistant
Let me look at an existing test that saves an execution and searches, to model a temporary end-to-end integration test.
Assistant
Let me write a temporary end-to-end integration test that saves an execution with a label and calls the search endpoint with the conditional-group + timeRange URL, asserting it returns 200 (not 400).
Assistant
Let me verify the imports (ExecutionMetadata, Label) exist with correct package paths.
Assistant
ExecutionMetadata doesn't have a
labelsfield. Let me check the Execution model for where labels are stored.Assistant
So
Executionhas alabelsfield directly (List). Let me update my test to useExecution.builder().labels(...)instead of metadata.Assistant
executionRepository.savereturns anExecution, not a reactive type. Let me check the signature.Assistant
The end-to-end integration test passes: the search endpoint returns 200 with the conditional group + timeRange, and the execution is found. This confirms the HTTP 400 is fixed.
Now let me confirm I didn't break the error path by running the
badQueryFilterstest, plus the existing utils tests.Assistant
badQueryFilters passes. Now let me run the JDBC-level tests that exercise the conditional groups SQL generation, to make sure START_DATE inside a node generates valid SQL. Let me check the AbstractJdbcExecutionRepository.find and how it calls filter() with dateColumn.
Assistant
Assistant
All 106 JDBC H2 execution repository tests pass, including the complex filter combinations with conditional groups. So my change doesn't break the SQL generation for nested groups.
Now let me review the final state of the modified files to ensure correctness.
Assistant
The code looks good. Let me check for any other places in main code that process TIME_RANGE at top-level only that I might have missed.
Assistant
The only places that process TIME_RANGE in main code are
QueryFilterUtilsandTimeLineSearch, which I've fixed. The JDBCtimeRangeConditionthrows as a safety net, but TIME_RANGE is resolved before reaching the repo. Let me verify whererewriteTriggerDateFiltersis called to ensure trigger flows also benefit.Assistant
rewriteTriggerDateFiltersis used by TriggerController, and I've made it recursive. So trigger flows with conditional groups + TIME_RANGE are also handled.Now let me clean up the temporary test files before submitting.
Assistant
Good. Only the two source files are modified. The temporary test files are removed. Let me do a final compile check to ensure the webserver compiles cleanly.
Assistant
Let me run the existing webserver tests for the modified files one final time to confirm everything passes after cleanup.
Assistant
All tests pass. Let me review the final diff to make sure everything is clean.
Assistant
The diff is clean. Let me do a final verification of the git status to confirm only the two source files are modified and no temporary test files remain.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.