Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kbn/config-schema] Improve OneOf error message format #84264

Open
mshustov opened this issue Nov 24, 2020 · 1 comment
Open

[kbn/config-schema] Improve OneOf error message format #84264

mshustov opened this issue Nov 24, 2020 · 1 comment
Labels
enhancement New value added to drive a business result kbn/config-schema Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@mshustov
Copy link
Contributor

mshustov commented Nov 24, 2020

The current error message for the failed .oneOf method is cryptic and not user friendly:

).toThrowErrorMatchingInlineSnapshot(`
"[authc.providers]: types that failed validation:
- [authc.providers.0]: expected value of type [array] but got [Object]
- [authc.providers.1.anonymous.anonymous1.credentials]: types that failed validation:
- [credentials.0.username]: expected value of type [string] but got [undefined]
- [credentials.1.apiKey]: types that failed validation:
- [credentials.apiKey.0.id]: expected value of type [string] but got [undefined]
- [credentials.apiKey.1]: expected value of type [string] but got [Object]"
`);

It's hard to reason about it. While the error doesn't provide details of the valid format (see https://github.com/elastic/kibana/blob/e3ca8a928dbb5fe2b844497a62f8875c8656deb5/x-pack/plugins/security/server/config.ts):

  • xpack.securuty.authc.providers is expected to be string[] | { [key]:{ description: string, icon: string, showInSelector: string }
  • xpack.securuty.authc.providers.anonymous.anonymous1.credentials is expected to be {username: string, password:string} | { apiKey: { id:string, key:string} | string } }
@mshustov mshustov added enhancement New value added to drive a business result Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc labels Nov 24, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@pgayvallet pgayvallet changed the title [kbn/config-schemaImprove error message format [kbn/config-schema] Improve error message format Nov 24, 2020
@mshustov mshustov changed the title [kbn/config-schema] Improve error message format [kbn/config-schema] Improve OneOf error message format Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result kbn/config-schema Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

No branches or pull requests

3 participants