elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.65k stars 8.23k forks source link

[Fleet]: Unreadable error appears when saving an enrollment token with name exclamation mark (!) #191719

Closed sukhwindersingh-qasource closed 2 months ago

sukhwindersingh-qasource commented 2 months ago

Kibana Build details:

VERSION: 8.16.0-SNAPSHOT BUILD: 77679 COMMIT: 6b091fe3b410eaae9d4805c0a3c0ea6168bf66b0

Preconditions:

  1. 8.16.0-SNAPSHOT Kibana cloud environment should be available.
  2. Policy should be present

Steps to reproduce:

  1. Navigate to the Fleet > enrollment token tab
  2. Create a enrollment token with the name "!"
  3. Observe unreadable error shows up

Expected Result:

Whats working:

Whats Not working:

Screen cast:

https://github.com/user-attachments/assets/c80dfe46-bfa7-49bc-8701-bd362a50b58c

elasticmachine commented 2 months ago

Pinging @elastic/fleet (Team:Fleet)

sukhwindersingh-qasource commented 2 months ago

@amolnater-qasource Please review

amolnater-qasource commented 2 months ago

Secondary review for this ticket is Done.

jillguyonnet commented 2 months ago

This caused a breach of our Fleet API SLO in serverless. See this Slack thread: https://elastic.slack.com/archives/C04J98D0PQW/p1724925768881849

I would say that at least processing the error more gracefully is definitely important for serverless. cc @kpollich

nchaulet commented 2 months ago

@jillguyonnet looks like the issue is when validation the name of the enrollment token here, if we remove that validation as the name contains an uuid too it will solve that issue

https://github.com/elastic/kibana/blob/main/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts#L363

jillguyonnet commented 2 months ago

So this seems to be caused by the use of (some of) query_string special characters (https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax) and is linked to the constraint that enrollment token names must be unique.

Since there was a discussion in https://github.com/elastic/kibana/issues/155550 about potentially removing this constraint, I've suggested a narrow fix in https://github.com/elastic/kibana/pull/191807.