Skip to content

[data.search] Add schema validation for custom strategies #161290

Open

Description

Currently, registering a custom search strategy requires the following:

  registerSearchStrategy: <
    SearchStrategyRequest extends IKibanaSearchRequest = IEsSearchRequest,
    SearchStrategyResponse extends IKibanaSearchResponse = IEsSearchResponse
  >(
    name: string,
    strategy: ISearchStrategy<SearchStrategyRequest, SearchStrategyResponse>
  ) => void;

The search strategy itself requires only a search method, and optionally accepts a cancel and extend method.

Right now, when using the data.search client-side services, the internal/search routes will be called, which have little schema validation:

        {
          request: {
            params: schema.object({
              strategy: schema.string(),
              id: schema.maybe(schema.string()),
            }),
            body: schema.object(
              // ...
              { unknowns: 'allow' }
            ),
          },
        }

We're already using Typescript generics for registering/calling the search strategies, so we should already have some definition for the expected types of the request/response shape. It would be nice if we actually added validation to ensure the request/response shape are what is expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Feature:SearchQuerying infrastructure in KibanaTeam:DataDiscoveryDiscover App Team (Document Explorer, Saved Search, Surrounding documents, Data, DataViews)impact:mediumAddressing this issue will have a medium level of impact on the quality/strength of our product.loe:mediumMedium Level of Efforttechnical debtImprovement of the software architecture and operational architecture

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions