[Fleet] Handle invalid YAML string values at API level when adding / editing integrations in policies #93926
Labels
Team:Fleet
Team label for Observability Data Collection Fleet team
technical debt
Improvement of the software architecture and operational architecture
Currently, when an invalid YAML string value to be used in a policy is sent to the
/api/fleet/package_policies
endpoint, the response contains the raw error from the YAML parser. As an example, this request, addingnginx
to the existing policy with ide233dc90-800a-11eb-b84c-bfaec6f37113
:(note the
"*foo"
in the value for"server_status_path"
) will result in the errorA valid string in this place would be
"\"*foo\""
. It needs to contain escaped double quotes so that the string that ends up in the policy is"*foo"
. Without that,*foo
is interpreted to be a YAML alias, which is not defined at this place and hence an invalid value.This error is thrown after the values have been replaced in the policy template, at this place https://github.com/elastic/kibana/blob/master/x-pack/plugins/fleet/server/services/epm/agent/agent.ts#L21 in the line
Invalid strings are already being caught by UI-side form validation when a user adds an integration to a policy (or edits it). (This was added in #93585 .) This does not help in the case when users use the API directly.
This task is to provide a better error message here to inform the API user of the problematic value:
NOTE Please see the discussion in #93585 -- at the time of this writing, the best known solution is NOT to add additional quotes to the string in this place, because this introduces other, different errors.
The text was updated successfully, but these errors were encountered: