Commit dd49c1a
# Backport
This will backport the following commits from `main` to `8.19`:
- [chore(axios,security-solution): remove axios from telemetry/role
scripts (#267944)](#267944)
<!--- Backport version: 9.6.6 -->
### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)
<!--BACKPORT [{"author":{"name":"Aleh
Zasypkin","email":"aleh.zasypkin@elastic.co"},"sourceCommit":{"committedDate":"2026-05-08T14:53:10Z","message":"chore(axios,security-solution):
remove axios from telemetry/role scripts (#267944)\n\n## Summary\n\n>
[!IMPORTANT]\n> **NOTE TO CODE OWNERS:** I'm modifying code I don't own
day to day.\nPlease verify the changes still work as expected. For these
migrations a\nquick run of the affected scripts/tests is worth more than
a code-only\nreview.\n\nThis PR removes the `axios` dependency for files
owned by\n`@elastic/security-solution`. Phase 4 of the axios migration
tracked\nunder #266556.\n\n### Why\n\nNode.js 22 ships a native `fetch`
API built on undici, and every browser\nKibana targets supports `fetch`
natively. Removing axios cuts one\nruntime dependency and continues the
per-team rollout that mirrors the\nearlier node-fetch
migration\n([#250719](#250719) and
siblings).\n\n### Changes\n\nThree files migrated, two files **deferred
to a later phase**:\n\n- `scripts/telemetry/build_ebt_data_view.ts`: 1
axios.get + 1 axios.put.\nReplaced with `fetch`, `res.ok` check, and
typed `await res.json()` for\nthe data-view fetch.\n-
`scripts/telemetry/build_ebt_data_view.test.ts`: was
mocking\n`axios.put` for `upsertRuntimeFields`. Switched to
`jest.spyOn(global,\n'fetch')`. The 16 existing test cases pass
unchanged in intent:\nname/type/url assertions adapted to read the
`fetch(url, init)` argument\nshape (`init.body` is now
`JSON.stringify(payload)` rather than the\nthird axios arg). Header
equality and dotted-name handling
assertions\nunchanged.\n-\n`server/lib/detection_engine/scripts/roles_users/create_role_and_user.ts`:\n2
axios.put calls. Replaced with `fetch` and an explicit non-2xx
throw\nthat preserves status+body in the error message.\n\nRemoved the
`scripts/telemetry/**` and\n`server/lib/detection_engine/scripts/**`
entries from\n`AXIOS_LEGACY_CONSUMERS` in `.eslintrc.js`. New axios
usage in either of\nthose directories is now blocked by the existing
global ban.\n\n**Deferred to a later
phase**:\n`server/integration_tests/configuration.test.ts`
and\n`server/integration_tests/telemetry.test.ts` mock `axios` at the
module\nlevel for code under `server/lib/telemetry/*`, which is owned
by\n`@elastic/security-data-analytics` and not yet migrated. Test mocks
must\nflip in lockstep with the production code they intercept; these
two\ntests will migrate alongside that team's PR.\n\n### Behavior
parity\n\nNative fetch does not throw on non-2xx, so each call site
explicitly\nchecks `res.ok` / `res.status`. Errors thrown inside the
migrated\nscripts now have the form `${status}:${body}` to keep the
same\ndiagnostic content the original axios errors carried. The diff
is\nintentionally minimal: variable names, comment placement,
try-catch\nstructure, and error-handling shape from the original axios
code
are\npreserved.","sha":"312e26c1241eb65a63c33c6d5acc3593ef6956d1","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["chore","release_note:skip","backport:all-open","v9.5.0"],"title":"chore(axios,security-solution):
remove axios from telemetry/role
scripts","number":267944,"url":"https://github.com/elastic/kibana/pull/267944","mergeCommit":{"message":"chore(axios,security-solution):
remove axios from telemetry/role scripts (#267944)\n\n## Summary\n\n>
[!IMPORTANT]\n> **NOTE TO CODE OWNERS:** I'm modifying code I don't own
day to day.\nPlease verify the changes still work as expected. For these
migrations a\nquick run of the affected scripts/tests is worth more than
a code-only\nreview.\n\nThis PR removes the `axios` dependency for files
owned by\n`@elastic/security-solution`. Phase 4 of the axios migration
tracked\nunder #266556.\n\n### Why\n\nNode.js 22 ships a native `fetch`
API built on undici, and every browser\nKibana targets supports `fetch`
natively. Removing axios cuts one\nruntime dependency and continues the
per-team rollout that mirrors the\nearlier node-fetch
migration\n([#250719](#250719) and
siblings).\n\n### Changes\n\nThree files migrated, two files **deferred
to a later phase**:\n\n- `scripts/telemetry/build_ebt_data_view.ts`: 1
axios.get + 1 axios.put.\nReplaced with `fetch`, `res.ok` check, and
typed `await res.json()` for\nthe data-view fetch.\n-
`scripts/telemetry/build_ebt_data_view.test.ts`: was
mocking\n`axios.put` for `upsertRuntimeFields`. Switched to
`jest.spyOn(global,\n'fetch')`. The 16 existing test cases pass
unchanged in intent:\nname/type/url assertions adapted to read the
`fetch(url, init)` argument\nshape (`init.body` is now
`JSON.stringify(payload)` rather than the\nthird axios arg). Header
equality and dotted-name handling
assertions\nunchanged.\n-\n`server/lib/detection_engine/scripts/roles_users/create_role_and_user.ts`:\n2
axios.put calls. Replaced with `fetch` and an explicit non-2xx
throw\nthat preserves status+body in the error message.\n\nRemoved the
`scripts/telemetry/**` and\n`server/lib/detection_engine/scripts/**`
entries from\n`AXIOS_LEGACY_CONSUMERS` in `.eslintrc.js`. New axios
usage in either of\nthose directories is now blocked by the existing
global ban.\n\n**Deferred to a later
phase**:\n`server/integration_tests/configuration.test.ts`
and\n`server/integration_tests/telemetry.test.ts` mock `axios` at the
module\nlevel for code under `server/lib/telemetry/*`, which is owned
by\n`@elastic/security-data-analytics` and not yet migrated. Test mocks
must\nflip in lockstep with the production code they intercept; these
two\ntests will migrate alongside that team's PR.\n\n### Behavior
parity\n\nNative fetch does not throw on non-2xx, so each call site
explicitly\nchecks `res.ok` / `res.status`. Errors thrown inside the
migrated\nscripts now have the form `${status}:${body}` to keep the
same\ndiagnostic content the original axios errors carried. The diff
is\nintentionally minimal: variable names, comment placement,
try-catch\nstructure, and error-handling shape from the original axios
code
are\npreserved.","sha":"312e26c1241eb65a63c33c6d5acc3593ef6956d1"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/267944","number":267944,"mergeCommit":{"message":"chore(axios,security-solution):
remove axios from telemetry/role scripts (#267944)\n\n## Summary\n\n>
[!IMPORTANT]\n> **NOTE TO CODE OWNERS:** I'm modifying code I don't own
day to day.\nPlease verify the changes still work as expected. For these
migrations a\nquick run of the affected scripts/tests is worth more than
a code-only\nreview.\n\nThis PR removes the `axios` dependency for files
owned by\n`@elastic/security-solution`. Phase 4 of the axios migration
tracked\nunder #266556.\n\n### Why\n\nNode.js 22 ships a native `fetch`
API built on undici, and every browser\nKibana targets supports `fetch`
natively. Removing axios cuts one\nruntime dependency and continues the
per-team rollout that mirrors the\nearlier node-fetch
migration\n([#250719](#250719) and
siblings).\n\n### Changes\n\nThree files migrated, two files **deferred
to a later phase**:\n\n- `scripts/telemetry/build_ebt_data_view.ts`: 1
axios.get + 1 axios.put.\nReplaced with `fetch`, `res.ok` check, and
typed `await res.json()` for\nthe data-view fetch.\n-
`scripts/telemetry/build_ebt_data_view.test.ts`: was
mocking\n`axios.put` for `upsertRuntimeFields`. Switched to
`jest.spyOn(global,\n'fetch')`. The 16 existing test cases pass
unchanged in intent:\nname/type/url assertions adapted to read the
`fetch(url, init)` argument\nshape (`init.body` is now
`JSON.stringify(payload)` rather than the\nthird axios arg). Header
equality and dotted-name handling
assertions\nunchanged.\n-\n`server/lib/detection_engine/scripts/roles_users/create_role_and_user.ts`:\n2
axios.put calls. Replaced with `fetch` and an explicit non-2xx
throw\nthat preserves status+body in the error message.\n\nRemoved the
`scripts/telemetry/**` and\n`server/lib/detection_engine/scripts/**`
entries from\n`AXIOS_LEGACY_CONSUMERS` in `.eslintrc.js`. New axios
usage in either of\nthose directories is now blocked by the existing
global ban.\n\n**Deferred to a later
phase**:\n`server/integration_tests/configuration.test.ts`
and\n`server/integration_tests/telemetry.test.ts` mock `axios` at the
module\nlevel for code under `server/lib/telemetry/*`, which is owned
by\n`@elastic/security-data-analytics` and not yet migrated. Test mocks
must\nflip in lockstep with the production code they intercept; these
two\ntests will migrate alongside that team's PR.\n\n### Behavior
parity\n\nNative fetch does not throw on non-2xx, so each call site
explicitly\nchecks `res.ok` / `res.status`. Errors thrown inside the
migrated\nscripts now have the form `${status}:${body}` to keep the
same\ndiagnostic content the original axios errors carried. The diff
is\nintentionally minimal: variable names, comment placement,
try-catch\nstructure, and error-handling shape from the original axios
code
are\npreserved.","sha":"312e26c1241eb65a63c33c6d5acc3593ef6956d1"}}]}]
BACKPORT-->
Co-authored-by: Aleh Zasypkin <aleh.zasypkin@elastic.co>
1 parent ef1fb30 commit dd49c1a
4 files changed
Lines changed: 55 additions & 48 deletions
File tree
- x-pack/solutions/security/plugins/security_solution
- scripts/telemetry
- server/lib/detection_engine/scripts/roles_users
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
348 | | - | |
349 | 348 | | |
350 | | - | |
351 | 349 | | |
352 | 350 | | |
353 | 351 | | |
| |||
Lines changed: 23 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 11 | + | |
18 | 12 | | |
19 | 13 | | |
20 | 14 | | |
| |||
26 | 20 | | |
27 | 21 | | |
28 | 22 | | |
29 | | - | |
| 23 | + | |
30 | 24 | | |
31 | 25 | | |
32 | 26 | | |
| |||
38 | 32 | | |
39 | 33 | | |
40 | 34 | | |
41 | | - | |
| 35 | + | |
42 | 36 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
49 | 47 | | |
50 | 48 | | |
51 | 49 | | |
52 | 50 | | |
53 | | - | |
54 | | - | |
55 | | - | |
| 51 | + | |
| 52 | + | |
56 | 53 | | |
57 | 54 | | |
58 | 55 | | |
59 | 56 | | |
60 | 57 | | |
| 58 | + | |
61 | 59 | | |
62 | 60 | | |
63 | 61 | | |
| |||
70 | 68 | | |
71 | 69 | | |
72 | 70 | | |
73 | | - | |
74 | | - | |
| 71 | + | |
| 72 | + | |
75 | 73 | | |
76 | 74 | | |
77 | | - | |
| 75 | + | |
| 76 | + | |
78 | 77 | | |
79 | 78 | | |
80 | 79 | | |
81 | | - | |
| 80 | + | |
82 | 81 | | |
83 | 82 | | |
84 | 83 | | |
| |||
88 | 87 | | |
89 | 88 | | |
90 | 89 | | |
91 | | - | |
| 90 | + | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
Lines changed: 13 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
62 | 61 | | |
63 | 62 | | |
64 | 63 | | |
65 | | - | |
66 | | - | |
67 | | - | |
| 64 | + | |
68 | 65 | | |
69 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
70 | 72 | | |
71 | | - | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
195 | 197 | | |
196 | 198 | | |
197 | 199 | | |
198 | | - | |
| 200 | + | |
| 201 | + | |
199 | 202 | | |
| 203 | + | |
200 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
201 | 208 | | |
202 | 209 | | |
203 | 210 | | |
| |||
Lines changed: 19 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
55 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | | - | |
73 | | - | |
74 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
| |||
0 commit comments