Skip to content

[Streams] Use original request for rules client when in default space#247014

Merged
cesco-f merged 2 commits intoelastic:mainfrom
cesco-f:fake-request
Dec 22, 2025
Merged

[Streams] Use original request for rules client when in default space#247014
cesco-f merged 2 commits intoelastic:mainfrom
cesco-f:fake-request

Conversation

@cesco-f
Copy link
Copy Markdown
Contributor

@cesco-f cesco-f commented Dec 19, 2025

Related to #239968.

Summary

Optimizes the QueryService to use the original request when operating from the default space, only creating a fake request bound to the default space when the request originates from a non-default space.

Problem

Previously, QueryService.getClientWithRequest() was unconditionally creating a fake request bound to the default space for the rules client, even when the original request was already coming from the default space. This was unnecessary overhead.

Solution

  • Added SpacesPluginStart as an optional dependency in StreamsPluginStartDependencies
  • Modified the logic to check the current space ID:
    • If the request is from the default space → use the original request
    • If the request is from a non-default space → use the fake request bound to the default space

@cesco-f cesco-f requested review from a team as code owners December 19, 2025 09:17
@cesco-f cesco-f added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Feature:Streams This is the label for the Streams Project labels Dec 19, 2025
@github-actions github-actions bot added the author:actionable-obs PRs authored by the actionable obs team label Dec 19, 2025
@cesco-f cesco-f added backport:version Backport to applied version labels v9.3.0 and removed backport:skip This PR does not require backporting labels Dec 22, 2025
@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

History

@cesco-f cesco-f merged commit 1a8a9dd into elastic:main Dec 22, 2025
13 checks passed
@cesco-f cesco-f deleted the fake-request branch December 22, 2025 14:26
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 9.3

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

@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
9.3 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 247014

Questions ?

Please refer to the Backport tool documentation

@cesco-f
Copy link
Copy Markdown
Contributor Author

cesco-f commented Dec 22, 2025

💚 All backports created successfully

Status Branch Result
9.3

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

Questions ?

Please refer to the Backport tool documentation

cesco-f added a commit to cesco-f/kibana that referenced this pull request Dec 22, 2025
…elastic#247014)

Related to elastic#239968.

## Summary

Optimizes the `QueryService` to use the original request when operating
from the default space, only creating a fake request bound to the
default space when the request originates from a non-default space.

## Problem

Previously, `QueryService.getClientWithRequest()` was unconditionally
creating a fake request bound to the default space for the rules client,
even when the original request was already coming from the default
space. This was unnecessary overhead.

## Solution

- Added `SpacesPluginStart` as an optional dependency in
`StreamsPluginStartDependencies`
- Modified the logic to check the current space ID:
- If the request is from the **default space** → use the original
request
- If the request is from a **non-default space** → use the fake request
bound to the default space

(cherry picked from commit 1a8a9dd)

# Conflicts:
#	x-pack/platform/plugins/shared/streams/server/lib/streams/assets/query/query_service.ts
mbondyra added a commit to mbondyra/kibana that referenced this pull request Dec 22, 2025
…d_step_back

* commit '51756d2722200a991607658d48ecda50aeb04a7d': (76 commits)
  [Synthetics] Fix SyncGlobalParamsSpaces flaky test (elastic#246487)
  [Synthetics] Fix useSyntheticsRules test (elastic#247259)
  [ES|QL] Fix index editor flaky test (elastic#247233)
  [ResponseOps][Reporting] Fix "failed to decrypt apiKey" error while disabling/enabling scheduled reports (elastic#247236)
  [Console] Update console definitions (main) (elastic#247214)
  [ES|QL] Esql indentation shortcut on the editor (elastic#247234)
  [Streams] Use original request for rules client when in default space (elastic#247014)
  Consolidate and improve unflattenObject (elastic#246725)
  [scout] use svl mode to run api-int tests (elastic#247223)
  SIEM Readiness V2 (elastic#245776)
  [ObsPresentation][A11y] Fix asset details flyout header announcement (elastic#246872)
  [Streams] Add abort support and silent mode for stream description generation (elastic#247082)
  [SLO] Add environment context to SLO feedback button (elastic#247221)
  Ignore the reason and retry systematically (elastic#246830)
  Update dependency @types/moment-duration-format to ^2.2.7 (main) (elastic#242221)
  [Streams 🌊 ] Add explicit waits for data grid rows before clicking expand button (elastic#246919)
  [Security Solution][Entity Analytics][Risk Scoring] Handle special characters in ESQL query for risk scoring (elastic#247060)
  [ML] Data frame analytics: Updates page headers (elastic#247097)
  [ES|QL] Build function arguments suggestions from hints (elastic#246736)
  Update dependency @hey-api/openapi-ts to v0.88.1 (main) (elastic#247210)
  ...
cesco-f added a commit that referenced this pull request Dec 22, 2025
… space (#247014) (#247275)

# Backport

This will backport the following commits from `main` to `9.3`:
- [[Streams] Use original request for rules client when in default space
(#247014)](#247014)

<!--- Backport version: 10.2.0 -->

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

<!--BACKPORT [{"author":{"name":"Francesco
Fagnani","email":"fagnani.francesco@gmail.com"},"sourceCommit":{"committedDate":"2025-12-22T14:25:56Z","message":"[Streams]
Use original request for rules client when in default space
(#247014)\n\nRelated to
https://github.com/elastic/kibana/issues/239968.\n\n##
Summary\n\nOptimizes the `QueryService` to use the original request when
operating\nfrom the default space, only creating a fake request bound to
the\ndefault space when the request originates from a non-default
space.\n\n## Problem\n\nPreviously,
`QueryService.getClientWithRequest()` was unconditionally\ncreating a
fake request bound to the default space for the rules client,\neven when
the original request was already coming from the default\nspace. This
was unnecessary overhead.\n\n## Solution\n\n- Added `SpacesPluginStart`
as an optional dependency in\n`StreamsPluginStartDependencies`\n-
Modified the logic to check the current space ID:\n- If the request is
from the **default space** → use the original\nrequest\n- If the request
is from a **non-default space** → use the fake request\nbound to the
default
space","sha":"1a8a9dd161a0bcd6c2bb5d62f727ee36f09ad78e","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","Feature:Streams","v9.3.0","v9.4.0","author:actionable-obs"],"title":"[Streams]
Use original request for rules client when in default
space","number":247014,"url":"https://github.com/elastic/kibana/pull/247014","mergeCommit":{"message":"[Streams]
Use original request for rules client when in default space
(#247014)\n\nRelated to
https://github.com/elastic/kibana/issues/239968.\n\n##
Summary\n\nOptimizes the `QueryService` to use the original request when
operating\nfrom the default space, only creating a fake request bound to
the\ndefault space when the request originates from a non-default
space.\n\n## Problem\n\nPreviously,
`QueryService.getClientWithRequest()` was unconditionally\ncreating a
fake request bound to the default space for the rules client,\neven when
the original request was already coming from the default\nspace. This
was unnecessary overhead.\n\n## Solution\n\n- Added `SpacesPluginStart`
as an optional dependency in\n`StreamsPluginStartDependencies`\n-
Modified the logic to check the current space ID:\n- If the request is
from the **default space** → use the original\nrequest\n- If the request
is from a **non-default space** → use the fake request\nbound to the
default
space","sha":"1a8a9dd161a0bcd6c2bb5d62f727ee36f09ad78e"}},"sourceBranch":"main","suggestedTargetBranches":["9.3"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/247014","number":247014,"mergeCommit":{"message":"[Streams]
Use original request for rules client when in default space
(#247014)\n\nRelated to
https://github.com/elastic/kibana/issues/239968.\n\n##
Summary\n\nOptimizes the `QueryService` to use the original request when
operating\nfrom the default space, only creating a fake request bound to
the\ndefault space when the request originates from a non-default
space.\n\n## Problem\n\nPreviously,
`QueryService.getClientWithRequest()` was unconditionally\ncreating a
fake request bound to the default space for the rules client,\neven when
the original request was already coming from the default\nspace. This
was unnecessary overhead.\n\n## Solution\n\n- Added `SpacesPluginStart`
as an optional dependency in\n`StreamsPluginStartDependencies`\n-
Modified the logic to check the current space ID:\n- If the request is
from the **default space** → use the original\nrequest\n- If the request
is from a **non-default space** → use the fake request\nbound to the
default space","sha":"1a8a9dd161a0bcd6c2bb5d62f727ee36f09ad78e"}}]}]
BACKPORT-->
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Jan 6, 2026
…elastic#247014)

Related to elastic#239968.

## Summary

Optimizes the `QueryService` to use the original request when operating
from the default space, only creating a fake request bound to the
default space when the request originates from a non-default space.

## Problem

Previously, `QueryService.getClientWithRequest()` was unconditionally
creating a fake request bound to the default space for the rules client,
even when the original request was already coming from the default
space. This was unnecessary overhead.

## Solution

- Added `SpacesPluginStart` as an optional dependency in
`StreamsPluginStartDependencies`
- Modified the logic to check the current space ID:
- If the request is from the **default space** → use the original
request
- If the request is from a **non-default space** → use the fake request
bound to the default space
dej611 pushed a commit to dej611/kibana that referenced this pull request Jan 8, 2026
…elastic#247014)

Related to elastic#239968.

## Summary

Optimizes the `QueryService` to use the original request when operating
from the default space, only creating a fake request bound to the
default space when the request originates from a non-default space.

## Problem

Previously, `QueryService.getClientWithRequest()` was unconditionally
creating a fake request bound to the default space for the rules client,
even when the original request was already coming from the default
space. This was unnecessary overhead.

## Solution

- Added `SpacesPluginStart` as an optional dependency in
`StreamsPluginStartDependencies`
- Modified the logic to check the current space ID:
- If the request is from the **default space** → use the original
request
- If the request is from a **non-default space** → use the fake request
bound to the default space
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:actionable-obs PRs authored by the actionable obs team backport:version Backport to applied version labels Feature:Streams This is the label for the Streams Project release_note:skip Skip the PR/issue when compiling release notes v9.3.0 v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants