[Fleet] Allow exclamation mark in enrollment token name
Summary
Closes https://github.com/elastic/kibana/issues/191719
Attempting to generate a Fleet enrollment token with a name that ends with ! produces a malformed ES query which causes POST agents/enrollment_api_keys to fail with 500.
This PR adds a narrow fix by escaping question marks (which is a query_string special character).
Note: this query probably wouldn't be necessary if we removed the constraint of unique name, as discussed in https://github.com/elastic/kibana/issues/155550.
:robot: GitHub comments
Expand to view the GitHub comments
Just comment with:
/oblt-deploy: Deploy a Kibana instance using the Observability test environments.rundocs-build: Re-trigger the docs validation. (use unformatted text in the comment!)
Pinging @elastic/fleet (Team:Fleet)
Thanks @juliaElastic!
There is a list of special characters: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax. I tried them all, most work besides some fairly unusual ones (&& for example). I thought about making a more robust function, but I wasn't sure the effort would be worth it considering we might eventually lift the name uniqueness constraint. WDYT?
There is a list of special characters: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax. I tried them all, most work besides some fairly unusual ones (
&&for example). I thought about making a more robust function, but I wasn't sure the effort would be worth it considering we might eventually lift the name uniqueness constraint. WDYT?
I agree, probably not worth putting more effort now. Thanks for confirming.
@elasticmachine merge upstream
:green_heart: Build Succeeded
- Buildkite Build
- Commit: 2a557426aa2fa9aee5662b54b2e520bcf61ca149
Metrics [docs]
✅ unchanged
History
- :broken_heart: Build #231046 failed 729aa9a6c2cd88e3fa0b85072441dc6a62f9f548
To update your PR or re-run it, just comment with:
@elasticmachine merge upstream
cc @jillguyonnet