Skip to content

[Response Ops] Es query rule "size" field re-initializes to 100 if set to 0 when editing#213636

Merged
doakalexi merged 5 commits intoelastic:mainfrom
doakalexi:bug/es-query-size
Mar 14, 2025
Merged

[Response Ops] Es query rule "size" field re-initializes to 100 if set to 0 when editing#213636
doakalexi merged 5 commits intoelastic:mainfrom
doakalexi:bug/es-query-size

Conversation

@doakalexi
Copy link
Contributor

@doakalexi doakalexi commented Mar 7, 2025

Resolves #209427

Summary

This PR fixes a bug when editing an es query rule with size set to 0. I also refactored the tests to use react testing library.

Checklist

Check the PR satisfies following conditions.

To verify

  1. Create an es query rule
  2. Set the size to be 0
  3. Save your rule
  4. Edit your rule and verify that the size is set to 0 when you open the editor

@doakalexi doakalexi changed the title Fixing size bug [Response Ops] Es query rule "size" field re-initializes to 100 if set to 0 when editing Mar 7, 2025
@doakalexi doakalexi added Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels v9.1.0 v8.19.0 labels Mar 10, 2025
@doakalexi doakalexi marked this pull request as ready for review March 13, 2025 14:17
@doakalexi doakalexi requested a review from a team as a code owner March 13, 2025 14:17
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@doakalexi doakalexi requested review from guskovaue and pmuellr March 13, 2025 14:17
Copy link
Contributor

@pmuellr pmuellr left a comment

Choose a reason for hiding this comment

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

LGTM, suggested a change that's valid (I hope), a little smaller, and catches nulls as well

thresholdComparator: thresholdComparator ?? DEFAULT_VALUES.THRESHOLD_COMPARATOR,
size: size ? size : isServerless ? SERVERLESS_DEFAULT_VALUES.SIZE : DEFAULT_VALUES.SIZE,
size:
size !== undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this test could be size != null, which would catch both null and undefined - for future-proofing in case the value becomes is null.

Looks like we can do that AND make this a little simpler:

size: 
  ruleParams.size ?? (isServerless ? SERVERLESS_DEFAULT_VALUES.SIZE : DEFAULT_VALUES.SIZE),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good idea, thank you! Updated in this commit c180f3f

thresholdComparator: thresholdComparator ?? DEFAULT_VALUES.THRESHOLD_COMPARATOR,
size: size ? size : isServerless ? SERVERLESS_DEFAULT_VALUES.SIZE : DEFAULT_VALUES.SIZE,
size:
size !== undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above re: size != null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in this commit c180f3f

: isServerless
? SERVERLESS_DEFAULT_VALUES.SIZE
: DEFAULT_VALUES.SIZE,
size:
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above re: size != null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in this commit c180f3f

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #86 / saved objects tagging - functional tests dashboard integration creating allows to create a tag from the tag selector

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
stackAlerts 73.2KB 73.3KB +78.0B

History

@doakalexi doakalexi merged commit 287eb3e into elastic:main Mar 14, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 14, 2025
…t to 0 when editing (elastic#213636)

Resolves elastic#209427

## Summary

This PR fixes a bug when editing an es query rule with size set to 0. I
also refactored the tests to use react testing library.

### Checklist

Check the PR satisfies following conditions.

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### To verify

1. Create an es query rule
2. Set the size to be 0
3. Save your rule
4. Edit your rule and verify that the size is set to 0 when you open the
editor

(cherry picked from commit 287eb3e)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

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

Questions ?

Please refer to the Backport tool documentation

@doakalexi
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.x

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

Questions ?

Please refer to the Backport tool documentation

doakalexi added a commit to doakalexi/kibana that referenced this pull request Mar 17, 2025
…t to 0 when editing (elastic#213636)

Resolves elastic#209427

## Summary

This PR fixes a bug when editing an es query rule with size set to 0. I
also refactored the tests to use react testing library.

### Checklist

Check the PR satisfies following conditions.

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### To verify

1. Create an es query rule
2. Set the size to be 0
3. Save your rule
4. Edit your rule and verify that the size is set to 0 when you open the
editor

(cherry picked from commit 287eb3e)
doakalexi added a commit that referenced this pull request Mar 18, 2025
… if set to 0 when editing (#213636) (#214848)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Response Ops] Es query rule "size" field re-initializes to 100 if
set to 0 when editing
(#213636)](#213636)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Alexi
Doak","email":"109488926+doakalexi@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-03-14T19:19:43Z","message":"[Response
Ops] Es query rule \"size\" field re-initializes to 100 if set to 0 when
editing (#213636)\n\nResolves
https://github.com/elastic/kibana/issues/209427\n\n## Summary\n\nThis PR
fixes a bug when editing an es query rule with size set to 0. I\nalso
refactored the tests to use react testing library.\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\n- [ ]
[Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n\n\n### To
verify\n\n1. Create an es query rule\n2. Set the size to be 0\n3. Save
your rule \n4. Edit your rule and verify that the size is set to 0 when
you open
the\neditor","sha":"287eb3e5c63fd7825993280c490f0dd9d774373a","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","backport:version","v9.1.0","v8.19.0"],"title":"[Response
Ops] Es query rule \"size\" field re-initializes to 100 if set to 0 when
editing","number":213636,"url":"https://github.com/elastic/kibana/pull/213636","mergeCommit":{"message":"[Response
Ops] Es query rule \"size\" field re-initializes to 100 if set to 0 when
editing (#213636)\n\nResolves
https://github.com/elastic/kibana/issues/209427\n\n## Summary\n\nThis PR
fixes a bug when editing an es query rule with size set to 0. I\nalso
refactored the tests to use react testing library.\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\n- [ ]
[Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n\n\n### To
verify\n\n1. Create an es query rule\n2. Set the size to be 0\n3. Save
your rule \n4. Edit your rule and verify that the size is set to 0 when
you open
the\neditor","sha":"287eb3e5c63fd7825993280c490f0dd9d774373a"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/213636","number":213636,"mergeCommit":{"message":"[Response
Ops] Es query rule \"size\" field re-initializes to 100 if set to 0 when
editing (#213636)\n\nResolves
https://github.com/elastic/kibana/issues/209427\n\n## Summary\n\nThis PR
fixes a bug when editing an es query rule with size set to 0. I\nalso
refactored the tests to use react testing library.\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\n- [ ]
[Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n\n\n### To
verify\n\n1. Create an es query rule\n2. Set the size to be 0\n3. Save
your rule \n4. Edit your rule and verify that the size is set to 0 when
you open
the\neditor","sha":"287eb3e5c63fd7825993280c490f0dd9d774373a"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
clintandrewhall pushed a commit to clintandrewhall/kibana that referenced this pull request Mar 20, 2025
…t to 0 when editing (elastic#213636)

Resolves elastic#209427

## Summary

This PR fixes a bug when editing an es query rule with size set to 0. I
also refactored the tests to use react testing library.

### Checklist

Check the PR satisfies following conditions. 

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios


### To verify

1. Create an es query rule
2. Set the size to be 0
3. Save your rule 
4. Edit your rule and verify that the size is set to 0 when you open the
editor
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Mar 22, 2025
…t to 0 when editing (elastic#213636)

Resolves elastic#209427

## Summary

This PR fixes a bug when editing an es query rule with size set to 0. I
also refactored the tests to use react testing library.

### Checklist

Check the PR satisfies following conditions. 

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios


### To verify

1. Create an es query rule
2. Set the size to be 0
3. Save your rule 
4. Edit your rule and verify that the size is set to 0 when you open the
editor
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 Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Response Ops] Es query rule "size" field re-initializes to 100 if set to 0 when editing

4 participants