-
Notifications
You must be signed in to change notification settings - Fork 72
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
Making read-only request breaks subsequent write requests #454
Comments
Does anyone have any temporary workarounds for this? My bug reporting tool shows I've ran into this issue 27,000+ times now 😅 |
I took a stab at it, but I just get |
Hi @marckohlbrugge ! I think your best bet at the moment is to reset the connection if the accept type is different from the one of the host you're passing. |
@chloelbn Thanks for the suggestion. Do you have any idea why marckohlbrugge@385b6b5 doesn't work as expected? I think the original implementation was meant to be something like this, considering the code comments referring to |
@chloelbn I was able to fix the bug with your suggestion of using the master...marckohlbrugge:master I couldn't get the test suite to run, so I haven't added any test coverage. Let me know if you'd like me to open a PR anyway. |
@marckohlbrugge a PR would be great indeed! Thanks a lot for your work! |
Before this change a read-only host could get memoized preventing writes in subsequent requests. Closes algolia#454
* Memoize host based on accept attribute Before this change a read-only host could get memoized preventing writes in subsequent requests. Closes #454 * Fix Rubocop issue by adding space Co-authored-by: Devin Beeuwkes <[email protected]> * Use hash instead of array Co-authored-by: Devin Beeuwkes <[email protected]> Co-authored-by: Devin Beeuwkes <[email protected]>
See algolia/algoliasearch-rails#397 for more background info.
Description
algoliasearch-client-ruby/lib/algolia/http/http_requester.rb
Lines 67 to 71 in 5e7c715
When making a read request the
HttpRequester
memoizes a@connection
with a read-only host. If afterwards you try to make a write request, thenHttpRequester
will ignore the supplied write host and instead use the memoized@connection
which was created with the read-only host. This leads to the following error:Algolia::AlgoliaHttpError: This host is read-only (ie. this is a DSN), write operations are not accepted
Steps To Reproduce
I'm using the
algoliasearch-rails
gem which I think makes acheck_settings
read-request automatically. So any write request fails. Here's a code example using justalgolia-client-ruby
:Proposed solution
Make sure the connection is specific to the provided host. Something along these lines:
The text was updated successfully, but these errors were encountered: