meilisearch / meilisearch-ruby

Ruby SDK for the Meilisearch API
https://meilisearch.com
MIT License
199 stars 44 forks source link

Ruby SDK not working with edge URL #522

Closed CaroFG closed 8 months ago

CaroFG commented 8 months ago

Description Description of what the bug is about. When using the edge URL with the ruby SDK, the following error is returned:

validate': 500 Internal Server Error - MeiliSearch API has not returned any error message. See <no documentation link found>. (MeiliSearch::ApiError)

This doesn't happen when using CURL.

It has been reported by a Cloud customer (private link) and I have reproduced it.

I have tried getting the stats and health.

Expected behavior What you expected to happen. When I get the health endpoiunt it should return: {"status":"available"} which is what it returns when using cURL.

Current behavior What happened.

/Users/carolina/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/meilisearch-0.27.0/lib/meilisearch/http_request.rb:131:in `validate': 500 Internal Server Error - MeiliSearch API has not returned any error message. See <no documentation link found>. (MeiliSearch::ApiError)
        from /Users/carolina/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/meilisearch-0.27.0/lib/meilisearch/http_request.rb:116:in `send_request'
        from /Users/carolina/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/meilisearch-0.27.0/lib/meilisearch/http_request.rb:26:in `http_get'
        from /Users/carolina/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/meilisearch-0.27.0/lib/meilisearch/client.rb:105:in `health'
        from index.rb:5:in `<main>'

Screenshots or Logs If applicable, add screenshots or logs to help explain your problem.

Environment (please complete the following information):

brunoocasali commented 8 months ago

The issue was found but not completely related to this gem. The ruby implementation was "lucky" enough to send "null" as a body even in GET requests, which were not allowed by our edge.meilisearch.com. So, I fixed the root cause. We may still want to fix it in the future, but we're not changing anything here right now.

Closing this issue! Feel free to reopen if needed.

ellnix commented 8 months ago

It looks like the reason for passing null as the body is that body gets converted to JSON before compact runs in http_config: https://github.com/meilisearch/meilisearch-ruby/blob/dcc99be1be5b2d2bbcca8516336988bf34814e42/lib/meilisearch/http_request.rb#L120

brunoocasali commented 8 months ago

Yeah, @ellnix I started to write a fix for it, but since the issue could be happening in other places, I changed my mind!