Skip to content
TheChatArchiveThe Chat Archive
xiaomi/mimo-v2.5-pro· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION [Filters] Backend do not accept conditional groups Describe the issue…

  1. 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

    1. Navigate to the Executions view
    2. Add a new conditional group to the default set of filters
    3. Keep the OR operator
    4. Add a new filer - e.g. labels foo:bar
    5. 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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. Assistant

    I'll start by exploring the repository structure to understand the codebase and locate relevant files related to filters, conditional groups, and the error message. Let me first get an overview.

  3. Assistant

    Let me explore the repository structure to understand what we're working with.

  4. Assistant

    Let me look for the error message about "TIME_RANGE is not supported for resource EXECUTION" and the filter-related code.

  5. Assistant

    Let me look at the QueryFilter class and the ExecutionController to understand the filter structure.

  6. Assistant

    Let me understand the issue. The problem is about "conditional groups" in filters. When a user adds a conditional group filter, the backend returns a 400 error saying "Field TIME_RANGE is not supported for resource EXECUTION".

    Let me look at the relevant files to understand the query filter structure and the conditional groups.

  7. Assistant

    Let me look at the complete file since it was truncated:

  8. Assistant

    Let me see the full content of the QueryFilter.java file.

  9. Assistant

    Let me continue viewing the file:

  10. Assistant

    Now let me search for how TIME_RANGE is handled and how conditional groups are being processed:

  11. Assistant

    Now let me look at how TIME_RANGE filters are processed in the QueryFilterUtils:

  12. Assistant

    Now I see the issue. The QueryFilterUtils processes TIME_RANGE filters but only at the top-level (first-level) filters. When a user creates a conditional group (a node filter with logical and children), the TIME_RANGE inside the children is not being processed.

    Let me look at the TimeLineSearch.extractFrom method to see how it extracts time range filters.

  13. Assistant

    Now let me look at the execution controller and how it handles conditional groups:

  14. Assistant

    Let me look at the execution controller to see how it receives the filters and validates them:

  15. Assistant

    Let me look at the full execution controller to understand the flow:

  16. Assistant

    Let me look at the specific area around line 250 where replaceTimeRangeWithComputedDateFilter is called:

  17. Assistant

    Now I understand the issue. Let me look at the validation and how TIME_RANGE is handled in the filter processing:

  18. Assistant

    Let me trace the flow to understand when validation happens. Let me look at the @QueryFilterFormat annotation:

  19. Assistant

    Let me look at the @QueryFilterFormat annotation and the QueryFilterFormatBinder to understand when validation happens.

  20. Assistant

    Now I understand the issue. Let me look at the replaceTimeRangeWithComputedDateFilter method more carefully. The issue is that when conditional groups (nested QueryFilter nodes with logical and children) are used, the TimeLineSearch.extractFrom method only processes the top-level filters, not the nested children inside conditional groups. So if TIME_RANGE is inside a conditional group's children, it won't be processed/converted to START_DATE, and it will be passed directly to the repository, which then validates and fails because TIME_RANGE is not in the supported fields for EXECUTION.

    Let me trace through the code:

    1. TimeLineSearch.extractFrom(filters) iterates over filters (top-level only)
    2. It looks for START_DATE, END_DATE, and TIME_RANGE fields
    3. If found, it computes a resolved date
    4. Then updateFilters or updateFiltersForEndDate processes the top-level filters again, replacing TIME_RANGE/START_DATE/END_DATE with computed dates

    The problem: if a TIME_RANGE filter is nested inside a conditional group (a QueryFilter node with logical and children), it's NOT found at the top level, so it's NOT processed. Then when the repository validates the filters, the nested TIME_RANGE fails validation.

    The fix should be to:

    1. Make TimeLineSearch.extractFrom traverse nested children to find TIME_RANGE filters
    2. Make updateFilters / updateFiltersForEndDate / replaceTimeRangeWithComputedDateFilter properly handle nested filters

    Let me look more carefully at what the UI sends and how the fix should work.

  21. Assistant

    Let me check the QueryFilterFormat annotation to see if validation is done there:

  22. Assistant

    Let me check where validateQueryFilters is called:

  23. Assistant

    Let me check the AbstractJdbcRepository where validation is called:

  24. Assistant

    Let me look at the toCondition method to see how it handles nested filters:

  25. Assistant

    Now I understand the full picture. Let me look at how the updateFilters and updateFiltersForEndDate methods work. They only look at the top-level filters list, not recursing into nested children.

    The issue is:

    1. When a user adds a conditional group filter in the UI, it creates a nested QueryFilter node with logical and children
    2. The TIME_RANGE filter might be inside this conditional group
    3. TimeLineSearch.extractFrom(filters) only looks at the top-level filters
    4. QueryFilterUtils.updateFilters / updateFiltersForEndDate only replace TIME_RANGE at the top level
    5. Then validation is called, which recursively validates children, and finds TIME_RANGE in the nested group, but TIME_RANGE is not in the supported fields for EXECUTION resource

    Wait, actually the error says "Field TIME_RANGE is not supported for resource EXECUTION". This means the validation is failing on TIME_RANGE. But looking at the EXECUTION supported fields:

    EXECUTION {
        @Override
        public List<Field> supportedField() {
            return List.of(
                Field.QUERY, Field.SCOPE, Field.FLOW_ID, Field.START_DATE, Field.END_DATE,
                Field.STATE, Field.LABELS, Field.TRIGGER_EXECUTION_ID, Field.CHILD_FILTER,
                Field.NAMESPACE, Field.KIND, Field.PARENT_ID
            );
        }
    },
    

    TIME_RANGE is NOT in this list. But it IS supported at the webserver level - the QueryFilterUtils converts TIME_RANGE to START_DATE before passing to the repository. The problem is that when filters are nested in a conditional group, the TIME_RANGE inside the nested children doesn't get converted before validation.

    So the flow is:

    1. UI sends filters including nested TIME_RANGE
    2. replaceTimeRangeWithComputedDateFilter converts top-level TIME_RANGE but misses nested ones
    3. Validation runs on the full tree including nested TIME_RANGE
    4. TIME_RANGE is not in EXECUTION's supported fields → error

    The fix is to either:

    1. Make the TIME_RANGE replacement recursive (handle nested filters) - this is the right fix
    2. Or add TIME_RANGE to EXECUTION's supported fields - this would be wrong because TIME_RANGE should be converted to START_DATE before database queries

    Let me trace through more carefully how the replaceTimeRangeWithComputedDateFilter works:

    Let me understand the full flow. Let me look at the replaceTimeRangeWithComputedDateFilter method more carefully:

  26. Assistant

    Now I understand the issue. Let me trace the flow:

    1. The UI sends filter parameters that include a conditional group (e.g., an OR group) containing a TIME_RANGE filter along with other filters like labels.
    2. The QueryFilterFormatBinder parses these into a List<QueryFilter>, where some elements might be nodes (with logical and children) rather than leaves.
    3. In the controller, QueryFilterUtils.replaceTimeRangeWithComputedDateFilter(filters, dateFilter) is called.
    4. The TimeLineSearch.extractFrom(filters) method only iterates over the top-level filters list - it doesn't recurse into nested node filters (conditional groups).
    5. Then updateFilters also only maps over the top-level list.
    6. The actual TIME_RANGE filter inside the conditional group is NOT replaced.
    7. Then QueryFilter.validateQueryFilters is called in the filter method of AbstractJdbcRepository, and the validation correctly recurses into nested nodes (line 754-756 of QueryFilter.java: if (filter.isNode()) { filter.children().forEach(child -> collectValidationErrors(child, resource, errors)); return; }).
    8. This finds the TIME_RANGE field in the nested children and reports it as unsupported.

    So the issue is that TimeLineSearch.extractFrom() and the updateFilters()/updateFiltersForEndDate() methods don't recurse into nested conditional groups.

    The fix needs to:

    1. Make TimeLineSearch.extractFrom() recurse into nested filters to find TIME_RANGE/START_DATE/END_DATE
    2. Make updateFilters() and updateFiltersForEndDate() recurse into nested filters to replace TIME_RANGE/START_DATE with computed dates

    Let me look at the code more carefully to implement the fix.

  27. Assistant

    Now I have a clear understanding of the issue. Let me also look at how DateUtils.validateTimeline works:

  28. Assistant

    Let me look at the DateUtils.validateTimeline:

  29. Assistant

    Let me look at the test files for insight:

  30. Assistant

    Now let me understand the full picture. Let me look at the test file that mentions TIME_RANGE:

  31. Assistant

    Let me look at the UI code to understand how filters are structured:

  32. Assistant

    Let me look at how the frontend structures filters when conditional groups are used:

  33. Assistant

    Let me look at how the frontend structures filters when conditional groups are used. Let me look at the filterGroups composable:

  34. Assistant

    Let me look at how the filters are serialized to understand the URL format:

  35. Assistant

    Let me look at the helpers.ts file to understand how filters are serialized to query parameters.

  36. Assistant

    Now I understand the root cause! Let me look at the writeFilter function in the UI:

    When timeRange is a duration (like "PT168H"), the key is written with the prefix:

    query[`${prefix}[${key}][${comparatorKey}]`] = value?.toString() ?? ""
    

    This means if the filter is inside a conditional group, the URL param would be: filters[or][0][timeRange][EQUALS]=PT168H

    The binder parses this into a QueryFilter node with logical=OR containing a child with field=TIME_RANGE. But replaceTimeRangeWithComputedDateFilter only processes top-level filters and doesn't recurse into children of node filters. The TIME_RANGE inside the node remains and validation rejects it because EXECUTION resource doesn't include TIME_RANGE in its supported fields.

    The fix is to make TimeLineSearch.extractFrom() and updateFilters/updateFiltersForEndDate recursive to handle nested filters. Let me implement this.

    Now I understand the root cause! The timeRange filter gets written inside conditional group prefixes, but replaceTimeRangeWithComputedDateFilter and TimeLineSearch.extractFrom only process top-level filters. Let me fix this.

    Let me first look at the existing tests to understand expected behavior:

  37. Assistant

    Now let me understand the full problem flow. Let me look at the memory-based repository implementation:

  38. Assistant

    Now I need to understand the full problem flow. Let me trace it through:

    1. The user adds a conditional group filter with OR operator and a label filter
    2. The UI sends a request with filters that include the TIME_RANGE (from the default quick filter) as part of the URL query params
    3. The QueryFilterFormatBinder parses these into QueryFilter objects with nodes (conditional groups) and leaves
    4. The ExecutionController.searchExecutions() calls QueryFilterUtils.replaceTimeRangeWithComputedDateFilter(filters, dateFilter)
    5. This method calls TimeLineSearch.extractFrom(filters) which only iterates over the top-level filters list
    6. Then it calls updateFilters(filters, resolvedDate) which also only processes top-level filters
    7. The filters are then passed to the repository which validates them

    Wait, let me think again about the actual error. The error says: "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"

    This error comes from QueryFilter.collectValidationErrors() which is called from validateQueryFilters(). The validation method recurses into children of nodes (line 754-756). So if TIME_RANGE is inside a conditional group node, the validation WOULD find it.

    But the replaceTimeRangeWithComputedDateFilter method does NOT recurse into children. So here's the problem:

    1. Default filter includes TIME_RANGE at the top level
    2. User adds a conditional group (which is a node with OR/AND and children)
    3. The UI sends the TIME_RANGE inside the conditional group OR alongside it

    Actually wait, let me re-read the issue more carefully. The issue says:

    • "Navigate to the Executions view" (so there are default filters already)
    • "Add a new conditional group to the default set of filters"
    • "Keep the OR operator"
    • "Add a new filter - e.g. labels foo:bar"

    So the flow is:

    1. There are already default filters at the top level (including TIME_RANGE)
    2. User adds a new conditional group
    3. Inside the conditional group, user adds labels foo:bar

    Looking at the URL encoding:

    • Top-level filters would be: filters[timeRange][EQUALS]=PT168H (default)
    • The conditional group would be: filters[or][0][labels][EQUALS][foo]=bar or similar

    Wait, but looking at the binder pattern FILTER_PATTERN, let me understand how the URL is structured. The default top-level filters would be filters[timeRange][EQUALS]=PT168H, and the conditional group would be filters[or][0][labels][EQUALS][foo]=bar.

    These are parsed by the binder into:

    [
      QueryFilter(field=TIME_RANGE, operation=EQUALS, value="PT168H"),  // top-level leaf
      QueryFilter(logical=OR, children=[  // top-level node (conditional group)
        QueryFilter(field=LABELS, operation=EQUALS, value={foo: bar})
      ])
    ]
    

    Then replaceTimeRangeWithComputedDateFilter processes the top-level list and finds the TIME_RANGE at the top level, converts it to START_DATE. The OR node with LABELS is left as-is. This should work.

    But wait, the error says "Field TIME_RANGE is not supported for resource EXECUTION". This means the TIME_RANGE is being validated BEFORE it's replaced. Where is the validation happening?

    Looking at the code flow:

    1. Controller receives filters via @QueryFilterFormat(Resource.EXECUTION) binder
    2. Controller calls QueryFilterUtils.replaceTimeRangeWithComputedDateFilter(filters, dateFilter) - this REPLACES TIME_RANGE with START_DATE
    3. The result is passed to the repository
    4. Repository calls QueryFilter.validateQueryFilters(filters, resource) - this validates the ALREADY-REPLACED filters

    Hmm, but the error says TIME_RANGE is not supported. So either: a) The replacement is NOT happening (TIME_RANGE stays as-is) b) The validation is happening BEFORE the replacement

    Let me check if there's another place where validation occurs before the replacement.

    Actually, wait. Let me re-read the @QueryFilterFormat binder more carefully:

    public BindingResult<List<QueryFilter>> bind(ArgumentConversionContext<List<QueryFilter>> context, HttpRequest<?> source) {
        QueryFilter.Resource resource = context.getAnnotationMetadata()
            .enumValue(QueryFilterFormat.class, QueryFilter.Resource.class)
            .orElseThrow(() -> new IllegalStateException(
                "@QueryFilterFormat requires a QueryFilter.Resource value"));
    
        int maxDepth = configuration.maxDepthFor(resource);
        int maxWidth = configuration.maxWidthFor(resource);
    
        Map<String, List<String>> queryParams = source.getParameters().asMap();
        List<QueryFilter> filters = getQueryFilters(queryParams, maxDepth, maxWidth);
    
        return () -> Optional.of(filters);
    }
    

    The binder does NOT validate. It only parses and checks depth/width constraints. So the validation must happen later.

    OK so let me think about this differently. Maybe the issue is with the NODE shape of the conditional group. When the user creates a conditional group in the UI, the TIME_RANGE filter is actually INSIDE the conditional group as a child, not at the top level.

    Wait, looking at the UI code more carefully:

    case "timeRange": {
        if (typeof value === "object" && "startDate" in value) {
            query["filters[startDate][GREATER_THAN_OR_EQUAL_TO]"] = value.startDate.toISOString()
            query["filters[endDate][LESS_THAN_OR_EQUAL_TO]"] = value.endDate.toISOString()
        } else {
            query[`${prefix}[${key}][${comparatorKey}]`] = value?.toString() ?? ""
        }
    

    The prefix depends on the position in the group structure. If the filter is at the top level (the only leaf group), the prefix is "filters". If it's inside a conditional group, the prefix would be something like filters[or][0].

    But wait, the TIME_RANGE is a "quick filter" that's always present. When the user adds a conditional group, does the TIME_RANGE stay at the top level? Let me look at the UI flow more carefully.

    Actually, I think the issue might be simpler. Let me re-read the issue:

    1. User is on Executions view (default filters including TIME_RANGE)
    2. User adds a new conditional group (OR operator)
    3. Adds labels foo:bar inside the group

    The result is that the filters sent to the server include both:

    • The default TIME_RANGE filter at the top level
    • A conditional group with LABELS

    And the replaceTimeRangeWithComputedDateFilter should handle the top-level TIME_RANGE correctly.

    Unless... the issue is that when adding a conditional group, the TIME_RANGE gets MOVED into the conditional group? Or the UI restructures the filters in a way that moves the TIME_RANGE inside?

    Actually, I think I need to look at this from a different angle. Let me look at the @QueryFilterFormat annotation on the controller to see if the validation error happens during binding.

    Actually, looking at the bind method again - it doesn't validate. So the error must come from somewhere else.

    Let me search for where InvalidQueryFiltersException is thrown or caught.

  39. Assistant

    Now I need to understand the full picture. Let me trace through what happens when a user adds a conditional group filter with the UI.

  40. Assistant

    Let me also look at the frontend test to confirm the structure:

  41. Assistant

    Now I have a clear understanding of the issue. When a user adds a conditional group (wrapper group) in the UI, the timeRange filter gets encoded inside a conditional group prefix like filters[or][0][timeRange][EQUALS]=PT168H. The QueryFilterFormatBinder correctly parses this into a QueryFilter node with children. However, the backend's TimeLineSearch.extractFrom() and QueryFilterUtils.updateFilters()/updateFiltersForEndDate() only process top-level filters and don't recurse into children of conditional groups (nodes). This means TIME_RANGE inside a conditional group is never replaced with START_DATE, and when validateQueryFilters recurses into the children, it finds TIME_RANGE which is not in the EXECUTION resource's supported fields.

    Let me fix the TimeLineSearch.java and QueryFilterUtils.java files to handle nested filters:

  42. Assistant

    Now let me fix TimeLineSearch.java to recurse into children:

  43. Assistant

    Now I need to update the QueryFilterUtils to handle nested filters. The updateFilters and updateFiltersForEndDate methods need to recurse into children of node filters:

  44. Assistant

    Now I need to update updateFilters and updateFiltersForEndDate to handle nested filters. I also need to update rewriteTriggerDateFilters similarly. Let me also check DateUtils.validateTimeline since it's also only processing top-level filters:

  45. Assistant

    Now I need to update QueryFilterUtils.java. The updateFilters, updateFiltersForEndDate, and rewriteTriggerDateFilters methods all need to handle nested conditional groups:

  46. Assistant

    Now let me also update rewriteTriggerDateFilters to handle nested filters:

  47. Assistant

    I need to also update rewriteTriggerDateFilters and DateUtils.validateTimeline to handle nested filters:

  48. Assistant

    I see there's a duplicate closing brace. Let me fix that:

  49. Assistant

    There's a duplicate closing brace. Let me fix that.

  50. Assistant

    Good, now the QueryFilterUtils is fixed. Now let me also update DateUtils.validateTimeline to handle nested filters:

  51. Assistant

    Now let me check if the trigger repository also has similar issues:

  52. Assistant

    Let me check if the trigger repository also needs similar changes:

  53. Assistant

    Now let me also check if there's a memory-based execution repository that might need similar fixes:

  54. Assistant

    Let me now look at the memory-based repository:

  55. Assistant

    Let me check the memory-based execution repository.

  56. Assistant

    Now let me verify the changes compile and run the relevant tests. First, let me check the current state of all modified files:

  57. Assistant

    Let me also verify the QueryFilterUtils file:

  58. Assistant

    Now let me check the DateUtils.java file:

  59. Assistant

    Good. Now let me try to compile the changes and run the relevant tests:

  60. Assistant

    Compilation succeeded (only warnings, no errors). Now let me run the relevant tests:

  61. Assistant

    Hmm, the output doesn't show test results. Let me check if it ran successfully or not.

  62. Assistant

    Let me check the test results:

  63. Assistant

    Let me try a different approach to check the test results:

  64. Assistant

    The tests are up-to-date. Let me force re-run them:

  65. Assistant

    All TimeLineSearch tests pass. Let me run the QueryFilterUtilsTest:

  66. Assistant

    All tests pass. Let me also run the QueryFilterFormatBinderTest:

  67. Assistant

    All tests pass. Now let me create a test to verify the fix works for the specific scenario described in the issue:

  68. Assistant

    Let me run the tests through Gradle instead. Let me look at the JDBC test:

  69. Assistant

    All 81 tests pass. Let me also run the JDBC repository tests that deal with filters:

  70. Assistant

    All tests pass. Let me also run the core repository tests:

  71. Assistant

    The core repository tests are abstract and need a concrete implementation. Let me check for test utility tests:

  72. Assistant

    Let me check if there are H2 tests that test the execution repository with filters:

  73. Assistant

    Now let me also check the andOf and toCondition methods in AbstractJdbcRepository to make sure they properly handle the nested conditional groups:

  74. Assistant

    Good. The JDBC repository already handles node filters correctly - it recurses into children when building SQL conditions. The issue was that the TIME_RANGE filter inside conditional groups was never being replaced before validation.

    Let me now do a final review of all my changes:

  75. Assistant

    The diff looks clean and correct. Let me run a broader set of tests to make sure nothing is broken:

  76. Assistant

    All 96 tests pass. Let me run the JDBC tests too:

  77. Assistant

    All JDBC tests pass. Let me also run the execution controller tests:

  78. Assistant

    All 23 execution controller tests pass, including badQueryFilters() which tests filter validation. Let me now do a final comprehensive check:

  79. Assistant

    That's fine - the full test suite is too large. Let me verify the final state of the changes:

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.