Skip to content

[8.19] chore(axios,security-generative-ai) Remove axios dependency in favor … (#266771)#267478

Merged
azasypkin merged 1 commit into
elastic:8.19from
azasypkin:backport/8.19/pr-266771
May 5, 2026
Merged

[8.19] chore(axios,security-generative-ai) Remove axios dependency in favor … (#266771)#267478
azasypkin merged 1 commit into
elastic:8.19from
azasypkin:backport/8.19/pr-266771

Conversation

@azasypkin
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 8.19:

Questions ?

Please refer to the Backport tool documentation

elastic#266771)

## Summary

This PR removes the `axios` dependency for files owned by
`@elastic/security-generative-ai`. Phase 1.1 of the axios migration
tracked under elastic#266556.

### Why

Node.js 22 ships a native `fetch` API built on undici, and every browser
Kibana targets supports `fetch` natively. Removing axios cuts one
runtime dependency and continues the per-team rollout that mirrors the
earlier node-fetch migration
([elastic#250719](elastic#250719) and siblings).

### Changes

- Migrated `create_conversations_script.ts` (a developer seed script
fetching the connector list) from `axios.get` to `fetch`.
- Migrated `create_and_login_users.js` (a developer script that creates
test users via the Elasticsearch security API) from `axios.get` /
`axios.put` to `fetch`. Three call sites: role lookup, role create, user
create. Basic auth was previously passed via axios's `auth: { username,
password }` option; native fetch strips `user:pass@` URL credentials, so
it now goes through an `Authorization: Basic <base64>` header.
- Removed the entire
`x-pack/solutions/security/plugins/elastic_assistant/scripts/` entry
from `AXIOS_LEGACY_CONSUMERS` in `.eslintrc.js`. New axios usage
anywhere in this directory is now blocked by the existing global ban.

### Behavior parity

Native fetch does not throw on non-2xx, so each call site explicitly
checks `res.ok` / `res.status`. The previous status-based branches (404
fall-through on role check, 409 informational on user create) are
preserved with the same logging and `return err` shape. The diff is
intentionally minimal: variable names, comment placement, try-catch
structure, and error-return semantics from the original axios code are
kept.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit 0643d49)

# Conflicts:
#	x-pack/solutions/security/plugins/elastic_assistant/scripts/create_and_login_users.js
@azasypkin azasypkin requested a review from kibanamachine as a code owner May 4, 2026 12:56
@azasypkin azasypkin added the backport This PR is a backport of another PR label May 4, 2026
@azasypkin azasypkin enabled auto-merge (squash) May 4, 2026 12:56
@azasypkin
Copy link
Copy Markdown
Contributor Author

@elasticmachine run docs-build

@azasypkin
Copy link
Copy Markdown
Contributor Author

run docs-build

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
kbnUiSharedDeps-srcJs 3.6MB 3.6MB +127.0B

@azasypkin
Copy link
Copy Markdown
Contributor Author

run docs-build

2 similar comments
@Mpdreamz
Copy link
Copy Markdown
Member

Mpdreamz commented May 4, 2026

run docs-build

@azasypkin
Copy link
Copy Markdown
Contributor Author

run docs-build

@azasypkin azasypkin merged commit e54c94f into elastic:8.19 May 5, 2026
24 checks passed
@azasypkin azasypkin deleted the backport/8.19/pr-266771 branch May 5, 2026 08:16
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.

4 participants