Skip to content

[CPS] onRequest handler improvements#253697

Merged
gsoldevila merged 8 commits into
elastic:mainfrom
gsoldevila:core-cps-onrequest-fallback
Feb 19, 2026
Merged

[CPS] onRequest handler improvements#253697
gsoldevila merged 8 commits into
elastic:mainfrom
gsoldevila:core-cps-onrequest-fallback

Conversation

@gsoldevila
Copy link
Copy Markdown
Member

@gsoldevila gsoldevila commented Feb 18, 2026

Summary

Closes https://github.com/elastic/kibana-team/issues/2845

Stripping project_routing

  • When CPS is disabled, the handler actively strips any project_routing present in body to prevent ES request failures.
  • When CPS is enabled and the request body contains a pit, the logic strips it away. Note that PIT-based searches define the project_routing globally when calling openPit.

Cleanup

The logic for request handling has been moved to a separate CpsRequestHandler class, preventing from cluttering the ElasticsearchService.

CPS config from configService

The setCpsFeatureFlag setter has been removed from the ElasticsearchServiceSetup contract. Instead, the ElasticsearchService now reads the cps.cpsEnabled configuration directly from the configService during setup. When cpsEnabled is false, the handler must still strip any project_routing information from the request.body.

@gsoldevila gsoldevila added Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Feb 18, 2026
@gsoldevila gsoldevila force-pushed the core-cps-onrequest-fallback branch 2 times, most recently from 4fb8d25 to bab1981 Compare February 18, 2026 12:49
}

public readonly onRequest: OnRequestHandler = (_ctx, params, _options) => {
if (!this.isServerless) return;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if serverless is false we still wanna run:

if (body?.project_routing != null) delete body.project_routing;

Right now that will be short circuited.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Addressed on 3313f7d

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-core (Team:Core)

@gsoldevila gsoldevila changed the title CPS onRequest handler: path-based fallback for direct transport.request() calls [CPS] onRequest handler improvements Feb 18, 2026
Copy link
Copy Markdown
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

For completeness 😊

Copy link
Copy Markdown
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

kibana-presentation changes LGTM
code review only

@gsoldevila gsoldevila enabled auto-merge (squash) February 19, 2026 10:41
gsoldevila and others added 8 commits February 19, 2026 14:47
…equest() calls

Co-authored-by: Cursor <cursoragent@cursor.com>
The ElasticsearchService now reads the cps.cpsEnabled config directly
from the configService during setup, removing the need for the
setCpsFeatureFlag setter pattern. The CpsRequestHandler is only
instantiated in serverless mode, and the onRequest handler is only
passed to ClusterClient when applicable.

Co-authored-by: Cursor <cursoragent@cursor.com>
…anch)

Co-authored-by: Cursor <cursoragent@cursor.com>
@gsoldevila gsoldevila force-pushed the core-cps-onrequest-fallback branch from 6e26d80 to dfda0dc Compare February 19, 2026 15:21
@gsoldevila gsoldevila merged commit 0fdbb86 into elastic:main Feb 19, 2026
16 checks passed
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/core-elasticsearch-server 56 55 -1
Unknown metric groups

API count

id before after diff
@kbn/core-elasticsearch-server 122 120 -2

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants