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

fix(insightsMiddleware): throw an error when credentials can't be extracted #4901

Merged
merged 3 commits into from
Sep 10, 2021

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Sep 8, 2021

Summary

When api or appId is missing, an error gets thrown by search insights, but that doesn't explain why that error gets thrown.

Ideally this would also clarify what the next step is (usually making sure to spread the previous search client, or leaving all properties in place, but i'm not too sure how to word that.

This doesn't add a new error where there wasn't already one, as the search-insights library threw an error in this case already.

Result

An error that explains when the search client doesn't match insights' expectation

…racted

When api or appId is missing, an error gets thrown by search insights, but that doesn't explain *why* that error gets thrown.

Ideally this would also clarify what the next step is (usually making sure to spread the previous search client, or leaving all properties in place, but i'm not too sure how to word that.

This doesn't add a new error where there wasn't already one, as the search-insights library threw an error in this case already.
@Haroenv Haroenv requested a review from eunjae-lee September 8, 2021 15:57
@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 8, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f812b80:

Sandbox Source
InstantSearch.js Configuration

@Haroenv Haroenv requested review from a team and francoischalifour and removed request for a team September 9, 2021 11:58
insightsClient,
})({ instantSearchInstance })
).toThrowErrorMatchingInlineSnapshot(
`"[insights middleware]: could not extract Algolia credentials from searchClient"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable, but I'm curious in which case searchClient didn't include the credentials? In that case, InstantSearch.js itself won't be functioning, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you do the following:

const client = algoliasearch()
const searchClient = {
  search: client.search // or intercept
}

In that case only the "required" methods are present, as well as with a "backend search" without an algolia client the insights-thrown error is confusing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, that makes sense.

@Haroenv Haroenv requested a review from eunjae-lee September 9, 2021 13:45
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

Successfully merging this pull request may close these issues.

2 participants