Skip to content

[9.5] [CPS] Fix CPS Scope Being Stamped Incorrectly (#280603)#280889

Open
hannahbrooks wants to merge 1 commit into
elastic:9.5from
hannahbrooks:backport/280603-9.5
Open

[9.5] [CPS] Fix CPS Scope Being Stamped Incorrectly (#280603)#280889
hannahbrooks wants to merge 1 commit into
elastic:9.5from
hannahbrooks:backport/280603-9.5

Conversation

@hannahbrooks

Copy link
Copy Markdown
Contributor

Backport

This will backport the following commit from main to 9.5:

Backported manually because the automated backport tool hit merge conflicts (test mocks in 9.5 still used the pre-refactor single esClient shape rather than main's internalUserEsClient/currentUserEsClient split). The conflicts were resolved by keeping 9.5's existing client shape and applying the same underlying fix: the /_project_routing/{npreName} response is { expression }, not { [npreName]: { expression } }.

Note: 9.3 and 9.4 are not backported — resolve_cps_data.ts doesn't exist on those branches (it was introduced by #266495 after they branched off), so there's nothing to fix there. 8.19 was intentionally skipped.

Questions?

Please refer to the Backport tool documentation

Made with Cursor

Closes elastic#279328

`GET /_project_routing/{npreName}` returns `{ expression }` but the code
was accessing it as `res[npreName].expression` — that key never exists,
so it always fell back to `_alias:*`.

Response type sourced from `NpreClient` in the CPS plugin
(`src/platform/plugins/shared/cps/server/npre/npre_client.ts`), which
calls the same endpoint and types the response as `{ expression:
ProjectRouting }`.

- Fixed the existing unit test mocks (they had the same wrong shape, so
they never caught this)
- Added a regression test: origin-routed space must stamp
`_alias:_origin`, not `_alias:*`

(cherry picked from commit b66d389)
@hannahbrooks
hannahbrooks marked this pull request as ready for review July 24, 2026 20:56
@hannahbrooks hannahbrooks self-assigned this Jul 24, 2026
@hannahbrooks hannahbrooks added the backport This PR is a backport of another PR label Jul 24, 2026
@kibanamachine
kibanamachine requested review from darnautov and removed request for kibanamachine July 24, 2026 20:57
@kibanamachine

Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #3 / ESQL execution logic API @ess @serverless ES|QL rule type preview logged requests should return requests with included data tiers filters from advanced settings
  • [job] [logs] Jest Tests #3 / EsqlQueryRuleTypeExpression should show grouped success message if Test Query is successful
  • [job] [logs] Scout Lane #10 - stateful-classic / default / local-stateful-classic - Discover app - errors - should render invalid scripted field error
  • [job] [logs] Scout Lane #11 - stateful-classic / default / local-stateful-classic - Entity attachment cases – flyout add-to-case actions and Entities accordion - Entities accordion renders when entity attachments were added via API
  • [job] [logs] Scout Lane #11 - stateful-classic / default / local-stateful-classic - Entity attachment cases – flyout add-to-case actions and Entities accordion - renders no Entities accordion when a case has no entity attachments

Metrics [docs]

✅ unchanged

cc @hannahbrooks

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

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants