Skip to content

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

@mshustov

Description

@mshustov

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 } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Team:CorePlatform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t//enhancementNew value added to drive a business resultkbn/config-schema

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions