[UnifiedSearch][ESQL] Fix edited query overwriting when a request is finished#224671
Conversation
|
/ci |
|
/ci |
src/platform/plugins/shared/unified_search/public/search_bar/search_bar.tsx
Show resolved
Hide resolved
| } | ||
| savedQuery={savedQuery} | ||
| onQuerySubmit={defaultOnQuerySubmit(props, data.query, query)} | ||
| onQueryChange={props.onQueryChange} |
There was a problem hiding this comment.
During my investigation I figured to, which onQueryChange is in the searcher props, we don't use it under the hood. seems we have no consumer for this, but we might need it in the future
There was a problem hiding this comment.
I'm always a little skeptical about changing such brittle and widely consumed code... I also don't get any results when checking for references, but that seemed to be the case for all props in SearchBarOwnProps that I checked, so something odd is going on. Just not sure if we should be worried about any odd side effects here since I'm unfamiliar with the code.
There was a problem hiding this comment.
I can definitely remove that, to keep it focused, from my perspective. it's not in use, and if it was used, it would not work, when in doubt, let's remove it, and fix it when we need it 👍 wdyt dear @elastic/kibana-presentation
There was a problem hiding this comment.
We don't have any more context at the moment, as we haven't had the bandwidth to really take ownership of this plugin quite yet.
There was a problem hiding this comment.
I've removed it for now, let's add it when we need it 👍
| } else if ( | ||
| nextProps.query && | ||
| isOfAggregateQueryType(nextProps.query) && | ||
| nextProps.query.esql !== get(prevState, 'currentProps.query.esql') |
There was a problem hiding this comment.
this is the main change, we mimic what KQL does. before this change, for ESQL the query was overwritten every time, since it was not checked if the new props value differs from the old one. Now this works.
I tried to cover this change with a unit test, but I couldn't make it work. Since on re-render the currentProps.query.esql, was not kept. This made the unit test pointless 🤷
I mean, we could refactor this part to a unit test, to a pure function. Open to apply this change if valued reviewers want to have it. Or have other ideas
There was a problem hiding this comment.
I'm not overly worried about it tbh, but I wonder if it's possible to test the rendered output in an RTL test? I might not understand exactly what was making it hard to test though. Otherwise a separate function like you mentioned would work if you're feeling proactive.
There was a problem hiding this comment.
Yes, I wanted to do this, I've tried and it didn't work, it might be me of course
There was a problem hiding this comment.
|
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
|
Pinging @elastic/kibana-esql (Team:ESQL) |
davismcphee
left a comment
There was a problem hiding this comment.
I'm not very familiar with the Unified Search code, but from what I can tell it LGTM and definitely fixes the issue in Discover 👍 Thanks for such a thorough investigation and getting to the bottom of this! Glad we didn't need to resort to any hacky workarounds in Discover 🙏
On a side note, maybe you're aware already, but a good approach for testing these types of changes is to use the ES|QL DELAY function like this:
FROM kibana_sample_data_logs | EVAL delay = DELAY(1000ms) | LIMIT 10
| } else if ( | ||
| nextProps.query && | ||
| isOfAggregateQueryType(nextProps.query) && | ||
| nextProps.query.esql !== get(prevState, 'currentProps.query.esql') |
There was a problem hiding this comment.
I'm not overly worried about it tbh, but I wonder if it's possible to test the rendered output in an RTL test? I might not understand exactly what was making it hard to test though. Otherwise a separate function like you mentioned would work if you're feeling proactive.
src/platform/plugins/shared/unified_search/public/search_bar/search_bar.tsx
Show resolved
Hide resolved
| } | ||
| savedQuery={savedQuery} | ||
| onQuerySubmit={defaultOnQuerySubmit(props, data.query, query)} | ||
| onQueryChange={props.onQueryChange} |
There was a problem hiding this comment.
I'm always a little skeptical about changing such brittle and widely consumed code... I also don't get any results when checking for references, but that seemed to be the case for all props in SearchBarOwnProps that I checked, so something odd is going on. Just not sure if we should be worried about any odd side effects here since I'm unfamiliar with the code.
|
Starting backport for target branches: 8.17, 8.18, 8.19 https://github.com/elastic/kibana/actions/runs/16045183087 |
💚 Build Succeeded
Metrics [docs]Async chunks
History
cc @kertal |
…finished (elastic#224671) Resolved overwriting changes to the query in the ESQL Editor in UnifiedSearch while the request is still running when the previous request finished (cherry picked from commit ca7b021)
💔 Some backports could not be created
Note: Successful backport PRs will be merged automatically after passing CI. Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
|
@kertal I dont think we need to backport it in v8.18 v8.19, v9.1 and main are enough. |
|
you're right, thx! |
|
Starting backport for target branches: 9.1 https://github.com/elastic/kibana/actions/runs/16046291859 |
|
Starting backport for target branches: 8.19, 9.1 https://github.com/elastic/kibana/actions/runs/16046294998 |
…finished (elastic#224671) Resolved overwriting changes to the query in the ESQL Editor in UnifiedSearch while the request is still running when the previous request finished (cherry picked from commit ca7b021)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…finished (elastic#224671) Resolved overwriting changes to the query in the ESQL Editor in UnifiedSearch while the request is still running when the previous request finished (cherry picked from commit ca7b021)
…finished (elastic#224671) Resolved overwriting changes to the query in the ESQL Editor in UnifiedSearch while the request is still running when the previous request finished (cherry picked from commit ca7b021)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…est is finished (#224671) (#226344) # Backport This will backport the following commits from `main` to `8.19`: - [[UnifiedSearch][ESQL] Fix edited query overwriting when a request is finished (#224671)](#224671) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Matthias Wilhelm","email":"matthias.wilhelm@elastic.co"},"sourceCommit":{"committedDate":"2025-07-03T08:14:41Z","message":"[UnifiedSearch][ESQL] Fix edited query overwriting when a request is finished (#224671)\n\nResolved overwriting changes to the query in the ESQL Editor in UnifiedSearch while the request is still running when the previous request finished","sha":"ca7b021814e3606434934c9dac0b1be8fbed4338","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:fix","Team:DataDiscovery","Feature:Unified search","backport:prev-major","Team:ESQL","v9.2.0"],"title":"[UnifiedSearch][ESQL] Fix edited query overwriting when a request is finished","number":224671,"url":"https://github.com/elastic/kibana/pull/224671","mergeCommit":{"message":"[UnifiedSearch][ESQL] Fix edited query overwriting when a request is finished (#224671)\n\nResolved overwriting changes to the query in the ESQL Editor in UnifiedSearch while the request is still running when the previous request finished","sha":"ca7b021814e3606434934c9dac0b1be8fbed4338"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/224671","number":224671,"mergeCommit":{"message":"[UnifiedSearch][ESQL] Fix edited query overwriting when a request is finished (#224671)\n\nResolved overwriting changes to the query in the ESQL Editor in UnifiedSearch while the request is still running when the previous request finished","sha":"ca7b021814e3606434934c9dac0b1be8fbed4338"}}]}] BACKPORT--> Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
…st is finished (#224671) (#226355) # Backport This will backport the following commits from `main` to `9.1`: - [[UnifiedSearch][ESQL] Fix edited query overwriting when a request is finished (#224671)](#224671) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Matthias Wilhelm","email":"matthias.wilhelm@elastic.co"},"sourceCommit":{"committedDate":"2025-07-03T08:14:41Z","message":"[UnifiedSearch][ESQL] Fix edited query overwriting when a request is finished (#224671)\n\nResolved overwriting changes to the query in the ESQL Editor in UnifiedSearch while the request is still running when the previous request finished","sha":"ca7b021814e3606434934c9dac0b1be8fbed4338","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:fix","Team:DataDiscovery","Feature:Unified search","Team:ESQL","backport:version","v9.1.0","v8.19.0","v9.2.0"],"title":"[UnifiedSearch][ESQL] Fix edited query overwriting when a request is finished","number":224671,"url":"https://github.com/elastic/kibana/pull/224671","mergeCommit":{"message":"[UnifiedSearch][ESQL] Fix edited query overwriting when a request is finished (#224671)\n\nResolved overwriting changes to the query in the ESQL Editor in UnifiedSearch while the request is still running when the previous request finished","sha":"ca7b021814e3606434934c9dac0b1be8fbed4338"}},"sourceBranch":"main","suggestedTargetBranches":["9.1"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/226344","number":226344,"state":"OPEN"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/224671","number":224671,"mergeCommit":{"message":"[UnifiedSearch][ESQL] Fix edited query overwriting when a request is finished (#224671)\n\nResolved overwriting changes to the query in the ESQL Editor in UnifiedSearch while the request is still running when the previous request finished","sha":"ca7b021814e3606434934c9dac0b1be8fbed4338"}}]}] BACKPORT--> Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
…finished (elastic#224671) Resolved overwriting changes to the query in the ESQL Editor in UnifiedSearch while the request is still running when the previous request finished
Summary
Resolves #192950
When changing the ESQL query while the request is still running, the changes were overwritten once the currently running request resolved. This PR fixes this behavior in UnifiedSearch by aligning to the way KQL works
How to test:
Note: I tried to cover this change with a unit test, but it didn't work, in several attempts, also the robot 🤖 was not helpful. Open for ideas (refactoring the change to a pure function would be doable, wanted to keep the scope of this fix small). So manually testing is the only way currently.
Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.