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 to understand its structure and locate relevant files. Let's first get an overview.
- Assistant
Let me explore the repository structure to understand the codebase and find the relevant filter/query filter code.
- Assistant
This looks like a Kestra repository (a workflow orchestration platform). The issue is about HTTP 400 error when using conditional group filters. Let me search for filter-related code.
- Assistant
Let me look at the QueryFilter model and the error message more closely.
- Assistant
Let me look for "ConditionalGroup" or "conditionalGroup" or "filter group" in the codebase.
- Assistant
Let me look at the error message more carefully: "Invalid query filters: Provided query filters are invalid: Field TIME_RANGE is not supported for resource EXECUTION." This error happens when a conditional group filter query is made. Let me look at the QueryFilter model and how filters are validated.
- Assistant
Let me look at the QueryFilter class to understand the structure better.
- Assistant
Let me look at the QueryFilter model and the validation code.
- Assistant
Let me look at the full QueryFilter.java file to see the EXECUTION resource's supported fields:
- Assistant
Let me see the EXECUTION resource definition and the supportedField method.
- Assistant
Let me look at the EXECUTION resource definition.
- Assistant
Now I understand the issue. The
TIME_RANGEfield is sent by the frontend for conditional groups but is not listed in theEXECUTIONresource'ssupportedField()list. Let me see howTIME_RANGEis handled elsewhere: - Assistant
Now I need to understand where the validation happens and how TIME_RANGE filters are processed. Let me look at the validation call sites.
- Assistant
Let me look at the validation code more carefully:
- Assistant
Now I understand the issue. The
TIME_RANGEfield is used by the frontend but gets transformed into concreteSTART_DATE/END_DATEfilters. However, when conditional groups are used, theTIME_RANGEfilter is passed directly to validation without being resolved first. Let me look at wherereplaceTimeRangeWithComputedDateFilteris called and how it interacts with conditional groups. - Assistant
Now let me look at the ExecutionController to understand the flow:
- Assistant
Let me look at the
@QueryFilterFormatannotation: - Assistant
Let me find the QueryFilterFormat annotation to understand how it works.
- Assistant
Let me look at the binder to understand how it validates filters:
- Assistant
Let me check where the validation happens in the repository and controller:
- Assistant
Now let me understand the issue better. Let me look at the search endpoint in ExecutionController:
- Assistant
I think I understand the issue now. Let me look at the
replaceTimeRangeWithComputedDateFiltermethod more carefully: - Assistant
Let me look at TimeLineSearch to understand how it extracts TIME_RANGE:
- Assistant
Now I'm understanding the issue. Let me look at the full test file for QueryFilter to see if there are tests for conditional groups with TIME_RANGE:
- Assistant
Now let me look at the issue more carefully. The problem is that
TimeLineSearch.extractFromonly looks at top-level filters, not at filters within conditional groups. Let me also check thereplaceTimeRangeWithComputedDateFiltermethod: - Assistant
Now I understand the issue clearly. The problem is that:
TimeLineSearch.extractFrom()only searches top-level filters for TIME_RANGE, not inside conditional groups (children)updateFilters()andupdateFiltersForEndDate()only replace TIME_RANGE at the top level, not inside conditional groups- When the TIME_RANGE filter is inside a conditional group, it doesn't get resolved to START_DATE/END_DATE, and then the validation in the repository rejects it because TIME_RANGE is not in the supported fields for EXECUTION
Let me look at the existing tests for this:
- Assistant
Now let me look at the
TimeLineSearch.extractFrommethod. It only iterates top-level filters, not recursively searching children of conditional groups: - Assistant
Now I have a clear picture of the issue. The problem is:
TimeLineSearch.extractFrom()only iterates top-level filters, not searching through conditional groups (children)updateFilters()andupdateFiltersForEndDate()only replace TIME_RANGE at the top level, not inside conditional groups- When TIME_RANGE is inside a conditional group's children, it's not resolved to START_DATE/END_DATE
- Then the validation in the repository catches TIME_RANGE which is not in the supported fields for EXECUTION
Let me also check the
rewriteTriggerDateFiltersmethod to see if it has the same issue: - Assistant
Now let me check if
DateUtils.validateTimelinealso has the same issue: - Assistant
Let me look at the DateUtils.validateTimeline to understand if it also doesn't handle conditional groups:
- Assistant
Now I understand the issue clearly. The problem is that:
TimeLineSearch.extractFrom()only looks at top-level filters (doesn't recurse into conditional group children)updateFilters(),updateFiltersForEndDate(), andrewriteTriggerDateFilters()only replace filters at the top level- When a TIME_RANGE filter ends up inside a conditional group (e.g., as a child of an OR group), it's never resolved to START_DATE/END_DATE
- When validation happens recursively in
collectValidationErrors(), it finds TIME_RANGE inside the children and rejects it
Let me now write a reproduction test first:
- Assistant
Now I understand the full issue. The fix needs to:
- Make
TimeLineSearch.extractFromrecursively search through conditional group children - Make
updateFilters,updateFiltersForEndDate, andrewriteTriggerDateFiltersrecursively update filters inside conditional groups
Let me implement the fix. First, let me modify
TimeLineSearch.extractFromto handle nested filters: - Make
- Assistant
Now I understand the full picture. Let me look at how the filters get processed in the execution controller to trace the flow from controller to repository:
- Assistant
Now I understand the full flow. The issue is:
When a user adds a conditional group to the filters in the UI, the TIME_RANGE filter can end up as a child of a conditional group node (OR/AND). However:
TimeLineSearch.extractFrom()only searches top-level filters, not children of conditional groupsupdateFilters()andupdateFiltersForEndDate()only replace TIME_RANGE at the top level- The TIME_RANGE inside the conditional group remains unresolved
- When validation happens recursively via
collectValidationErrors(), it finds the TIME_RANGE in children and rejects it
Now let me implement the fix. I need to make both
TimeLineSearch.extractFrom()and the update methods handle recursive filter structures: - Assistant
Let me try a different approach to editing the files:
- Assistant
Let me try using
pythoninstead ofpython3, orsed: - Assistant
Let me try to use the edit command with the --file option:
- Assistant
Let me try using the
editcommand with the--fileoption: - Assistant
Good, the TimeLineSearch is updated. Now I need to update the
updateFiltersandupdateFiltersForEndDatemethods inQueryFilterUtils.javato handle conditional groups recursively: - Assistant
Now I need to update the
updateFiltersmethod to handle conditional groups: - Assistant
Now I need to add the
hasDateFilterRecursivehelper method and updateupdateFiltersForEndDatesimilarly. Let me also updaterewriteTriggerDateFilters: - Assistant
Now I need to update
rewriteTriggerDateFiltersto also handle conditional groups: - Assistant
Now I need to update the
rewriteTriggerDateFiltersmethod to also handle conditional groups: - Assistant
Good, now let me verify the complete file to make sure everything looks correct:
- Assistant
Now let me also check if
DateUtils.validateTimelineneeds to handle recursive filters. Let me look at it: - Assistant
The
DateUtils.validateTimelinealso iterates top-level filters only, but it's called after filters are already resolved so it should be okay. Let me now run the existing tests to see if my changes break anything:The
DateUtils.validateTimeline(List<QueryFilter>)also only looks at top-level filters, but since it's called after the TIME_RANGE resolution, it should be fine. The key fix is in the three methods I updated. Let me now run the existing tests to verify my changes don't break anything: - Assistant
All 81 tests pass. Now let me run the core model tests as well:
- Assistant
All 730 tests pass. Let me also run the QueryFilterFormatBinderTest:
- Assistant
All tests pass. Let me verify the final state of both files to make sure everything is correct:
- Assistant
Now let me also check the QueryFilterUtils file to make sure it's correct.
- Assistant
Good, the code looks correct. Now let me also think about edge cases. The
collectValidationErrorsin QueryFilter already handles nodes recursively, so the validation was fine - the problem was just that TIME_RANGE wasn't being resolved before reaching validation.Let me also check if there are other places that might iterate over filters without handling conditional groups. Let me search for similar patterns in the codebase.
Let me also check if there are other places that might need similar recursive handling. Let me search for patterns where filters are iterated without handling nodes:
- Assistant
Now let me also check the
DateUtils.validateTimeline(List<QueryFilter>)which also only handles top-level filters: - Assistant
Now let me think about whether I need to also update
DateUtils.validateTimeline(List<QueryFilter>). Looking at the flow,validateTimelineis called afterupdateFiltershas already resolved the TIME_RANGE filters into START_DATE/END_DATE, so it should be fine. But let me check if there are any cases where this might not be true.Actually, the
DateUtils.validateTimelinemethod only looks at top-level filters too, but since theupdateFiltersandupdateFiltersForEndDatemethods now recursively handle conditional groups, by the timevalidateTimelineis called, any TIME_RANGE filters inside children would already be resolved to START_DATE/END_DATE. So thevalidateTimelinemethod should still work correctly.But wait, there's a potential issue: if the user has a START_DATE filter inside a conditional group, the
validateTimelinemethod won't find it. But this is a pre-existing issue that's not related to the current bug report. The issue only mentions TIME_RANGE, not START_DATE/END_DATE inside conditional groups.Let me also think about the
rewriteTriggerDateFiltersmethod. I already updated it to handle conditional groups. Let me verify it's correct. - Assistant
Let me run all the tests again to make sure everything still works:
- Assistant
All 96 tests pass. Let me also run the core tests to make sure the DateUtils change didn't break anything:
- Assistant
Let me run a broader set of tests to make sure nothing is broken:
- Assistant
There's no specific DateUtilsTest, so let me check if there's any test for DateUtils:
- Assistant
Let me now also check if there are other places in the codebase that may need similar fixes for recursive filter handling:
- Assistant
Let me check if the AbstractJdbcRepository also handles TIME_RANGE and has similar issues:
- Assistant
Let me look at the relevant section in AbstractJdbcRepository:
- Assistant
Good, I can see that the
AbstractJdbcRepositoryhas atimeRangeConditionthat throws an error for TIME_RANGE at the database level. But the issue is that TIME_RANGE should be resolved to START_DATE/END_DATE by theQueryFilterUtils.replaceTimeRangeWithComputedDateFilterbefore reaching the repository.With my fix, the
TimeLineSearch.extractFromnow recursively searches through conditional groups, andupdateFilters/updateFiltersForEndDatenow recursively replace TIME_RANGE/START_DATE/END_DATE filters inside conditional groups.Let me run a broader test suite to make sure everything works:
- Assistant
All 96 tests pass. Let me also run the core QueryFilterTest to make sure the validation tests still work:
- Assistant
All tests pass. Let me also check if there's an issue with the
AbstractJdbcTriggerRepositorysince it also mentions TIME_RANGE: - Assistant
Now I realize there's a subtle issue with my fix to
updateFiltersandupdateFiltersForEndDate. When they recurse into children of a conditional group, the!hasDateFiltercheck might add a default START_DATE/END_DATE filter inside the conditional group, which would be wrong. The default filter should only be added at the top level.Let me fix this by only adding the default at the top level:
- Assistant
Now let me also fix the same issue in
updateFiltersForEndDate: - Assistant
Now let me run the tests again to make sure everything still works:
- Assistant
All 96 tests pass. Let me now do a final review of all the changes I made:
- Assistant
The diff looks clean and comprehensive. Let me do one final check to make sure I haven't missed anything. Let me verify the final state of all changed files:
- Assistant
Let me run one final comprehensive test to make sure everything is working correctly:
- Assistant
All 96 tests pass. Let me also check if there are any integration tests related to execution search that might be affected:
- Assistant
Let me check if there are any tests specifically for conditional groups with filters in the execution controller tests:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.