Skip to content

Bulk operations support gap_range#221078

Merged
nkhristinin merged 16 commits intoelastic:mainfrom
nkhristinin:gaps-filter
Jun 10, 2025
Merged

Bulk operations support gap_range#221078
nkhristinin merged 16 commits intoelastic:mainfrom
nkhristinin:gaps-filter

Conversation

@nkhristinin
Copy link
Contributor

@nkhristinin nkhristinin commented May 21, 2025

Bulk operations support gap_range

issue

Bug

If a user has 100 rules in total and 20 of them have gaps:

  • They click "Show only with gaps" — the UI shows just those 20.
  • They hit "Select all" — it says 20 rules are selected.
  • But when they perform a bulk action, it ends up applying to all 100 rules, not just the 20 with gaps.

This happens because the bulk action uses a query that doesn't include gap info, so it ends up targeting everything.

Fix

We now support passing gaps_range_start and gaps_range_end along with the bulk action.

On the API side:

  • If a query is sent, we use the gap range to find the actual list of rule IDs with gaps.
  • Then we apply the bulk action only to those rules.

@nkhristinin
Copy link
Contributor Author

/ci

@nkhristinin
Copy link
Contributor Author

/ci

@nkhristinin
Copy link
Contributor Author

/ci

@nkhristinin
Copy link
Contributor Author

/ci

@nkhristinin nkhristinin changed the title Support gap range in bulk actions Bulk operations support gap_range May 22, 2025
@nkhristinin
Copy link
Contributor Author

/ci

@nkhristinin nkhristinin marked this pull request as ready for review May 26, 2025 05:54
@nkhristinin nkhristinin requested a review from a team as a code owner May 26, 2025 05:54
@nkhristinin nkhristinin requested a review from nikitaindik May 26, 2025 05:54
@nkhristinin
Copy link
Contributor Author

@elasticmachine merge upstream

@nkhristinin nkhristinin added release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor backport:version Backport to applied version labels v8.19.0 v9.0.3 labels May 26, 2025
@nkhristinin
Copy link
Contributor Author

@elasticmachine merge upstream

@jkelas jkelas requested review from jkelas and removed request for nikitaindik May 30, 2025 07:46
Copy link
Contributor

@jkelas jkelas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that the code is OK and tests verify it correctly, however I left some comments for some small improvements and adding some tests.

I verified that functionality works fine. I installed 4 rules. I made the 2 of them have gaps. When I select "show only with gaps", and run bulk action "duplicate", only the 2 rules with gaps are duplicated.

Please address my comments @nkhristinin and then I will approve.

Video from verification:

Screen.Recording.2025-05-30.at.12.16.59.mov

const MAX_RULES_TO_BULK_EDIT = 2000;
const MAX_ROUTE_CONCURRENCY = 5;

const validateBulkAction = (body: PerformRulesBulkActionRequestBody) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add some typing:

type ValidationError = { body: string; statusCode: number };

const validateBulkAction = (
  body: PerformRulesBulkActionRequestBody
): ValidationError | undefined => {

body: `Both gaps_range_start and gaps_range_end must be provided together.`,
statusCode: 400,
};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And return undefined explicitly at the bottom:

return undefined; // ✅ valid input

Copy link
Contributor

@jkelas jkelas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nkhristinin thank you for implementing my remarks. I reviewed the code again and I am approving. Good job.

@nkhristinin
Copy link
Contributor Author

@elasticmachine merge upstream

@nkhristinin
Copy link
Contributor Author

@elasticmachine merge upstream

@nkhristinin nkhristinin enabled auto-merge (squash) June 10, 2025 07:44
@nkhristinin nkhristinin merged commit 4703f76 into elastic:main Jun 10, 2025
10 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.18, 8.19, 9.0

https://github.com/elastic/kibana/actions/runs/15556333623

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 9.3MB 9.3MB +400.0B

History

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.18 Backport failed because of merge conflicts
8.19 Backport failed because of merge conflicts
9.0 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 221078

Questions ?

Please refer to the Backport tool documentation

pmuellr pushed a commit to pmuellr/kibana that referenced this pull request Jun 11, 2025
## Bulk operations support `gap_range`

[issue](elastic#220772)
### Bug   
If a user has 100 rules in total and 20 of them have gaps:
- They click "Show only with gaps" — the UI shows just those 20.
- They hit "Select all" — it says 20 rules are selected.
- But when they perform a bulk action, it ends up applying to **all 100
rules**, not just the 20 with gaps.

This happens because the bulk action uses a query that doesn't include
gap info, so it ends up targeting everything.

### Fix  
We now support passing `gaps_range_start` and `gaps_range_end` along
with the bulk action.

On the API side:
- If a query is sent, we use the gap range to find the actual list of
rule IDs with gaps.
- Then we apply the bulk action only to those rules.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jun 11, 2025
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 221078 locally
cc: @nkhristinin

@nkhristinin
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.
cc: @nkhristinin

nickpeihl pushed a commit to nickpeihl/kibana that referenced this pull request Jun 12, 2025
## Bulk operations support `gap_range`

[issue](elastic#220772)
### Bug   
If a user has 100 rules in total and 20 of them have gaps:
- They click "Show only with gaps" — the UI shows just those 20.
- They hit "Select all" — it says 20 rules are selected.
- But when they perform a bulk action, it ends up applying to **all 100
rules**, not just the 20 with gaps.

This happens because the bulk action uses a query that doesn't include
gap info, so it ends up targeting everything.

### Fix  
We now support passing `gaps_range_start` and `gaps_range_end` along
with the bulk action.

On the API side:
- If a query is sent, we use the gap range to find the actual list of
rule IDs with gaps.
- Then we apply the bulk action only to those rules.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.
cc: @nkhristinin

iblancof pushed a commit to iblancof/kibana that referenced this pull request Jun 16, 2025
## Bulk operations support `gap_range`

[issue](elastic#220772)
### Bug   
If a user has 100 rules in total and 20 of them have gaps:
- They click "Show only with gaps" — the UI shows just those 20.
- They hit "Select all" — it says 20 rules are selected.
- But when they perform a bulk action, it ends up applying to **all 100
rules**, not just the 20 with gaps.

This happens because the bulk action uses a query that doesn't include
gap info, so it ends up targeting everything.

### Fix  
We now support passing `gaps_range_start` and `gaps_range_end` along
with the bulk action.

On the API side:
- If a query is sent, we use the gap range to find the actual list of
rule IDs with gaps.
- Then we apply the bulk action only to those rules.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.
cc: @nkhristinin

1 similar comment
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.
cc: @nkhristinin

nkhristinin added a commit that referenced this pull request Jun 18, 2025
# Backport

This will backport the following commits from `main` to `8.19`:
- [Bulk operations support `gap_range`
(#221078)](#221078)

<!--- Backport version: 10.0.0 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Khristinin
Nikita","email":"nikita.khristinin@elastic.co"},"sourceCommit":{"committedDate":"2025-06-10T09:52:32Z","message":"Bulk
operations support `gap_range` (#221078)\n\n## Bulk operations support
`gap_range`\n\n[issue](https://github.com/elastic/kibana/issues/220772)\n###
Bug \nIf a user has 100 rules in total and 20 of them have gaps:\n- They
click \"Show only with gaps\" — the UI shows just those 20.\n- They hit
\"Select all\" — it says 20 rules are selected.\n- But when they perform
a bulk action, it ends up applying to **all 100\nrules**, not just the
20 with gaps.\n\nThis happens because the bulk action uses a query that
doesn't include\ngap info, so it ends up targeting everything.\n\n###
Fix \nWe now support passing `gaps_range_start` and `gaps_range_end`
along\nwith the bulk action.\n\nOn the API side:\n- If a query is sent,
we use the gap range to find the actual list of\nrule IDs with gaps.\n-
Then we apply the bulk action only to those
rules.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"4703f7629eb86c1b76297209d244c3aa2e6d5de6","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport
missing","backport:prev-minor","backport:version","v8.18.3"],"title":"Bulk
operations support
`gap_range`","number":221078,"url":"https://github.com/elastic/kibana/pull/221078","mergeCommit":{"message":"Bulk
operations support `gap_range` (#221078)\n\n## Bulk operations support
`gap_range`\n\n[issue](https://github.com/elastic/kibana/issues/220772)\n###
Bug \nIf a user has 100 rules in total and 20 of them have gaps:\n- They
click \"Show only with gaps\" — the UI shows just those 20.\n- They hit
\"Select all\" — it says 20 rules are selected.\n- But when they perform
a bulk action, it ends up applying to **all 100\nrules**, not just the
20 with gaps.\n\nThis happens because the bulk action uses a query that
doesn't include\ngap info, so it ends up targeting everything.\n\n###
Fix \nWe now support passing `gaps_range_start` and `gaps_range_end`
along\nwith the bulk action.\n\nOn the API side:\n- If a query is sent,
we use the gap range to find the actual list of\nrule IDs with gaps.\n-
Then we apply the bulk action only to those
rules.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"4703f7629eb86c1b76297209d244c3aa2e6d5de6"}},"sourceBranch":"main","suggestedTargetBranches":["8.18"],"targetPullRequestStates":[{"branch":"8.18","label":"v8.18.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@kibanamachine kibanamachine added v8.19.0 and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes v8.18.3 v8.19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants