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

Response Type is not thorough when making a multiSearch with an API key that has gone out of quota. #202

Open
CestDiego opened this issue Apr 28, 2024 · 1 comment

Comments

@CestDiego
Copy link

CestDiego commented Apr 28, 2024

Description

My OpenAI API Key seems to have exceeded it's current quota, and it returned the following instead of a SearchResponse type.

{
  results: [
    {
      code: 400,
      error: 'OpenAI API error: You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.'
    }
  ]
}

Steps to reproduce

Use an OpenAI Key that has exceeded quota.

Expected Behavior

There should be a union type for the SearchResponse type to have a type guard check for errors in the multiSearch.perform
I was doing the following:

  const { results } = await TypesenseClient.multiSearch.perform<
    SearchSpacesHit[]
  >(searchRequest, commonSearchParams);
  console.log({ results });
  return {
    hits: results.length > 0 ? results[0].hits : [],
  };

Actual Behavior

I get no visibility of the errors in the types and so I gotta add a lot of linter-ignores to be able to check whether the first result of my search had an error code.

Metadata

Typesense Version: "typesense": "^1.8.2",

OS: MacOS

@jasonbosco jasonbosco transferred this issue from typesense/typesense Apr 28, 2024
@jasonbosco
Copy link
Member

Thank you for catching this.

I’d appreciate a PR, otherwise I can patch this next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants