-
Notifications
You must be signed in to change notification settings - Fork 90
Meilisearch is sending a body on GET requests #762
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
Comments
I don't think this is intentional, and I know why it is happening. I'm verifying now that changing it won't break anything. If I find fixing it doesn't break anything and you want the PR I can report back with what change is needed. I also don't mind updating it if you don't have time. Either way is good for me. |
Alright, what we need to do is update send_requests to: def send_request(
self,
http_method: Callable,
path: str,
body: Optional[Union[Dict[str, Any], List[Dict[str, Any]], List[str], str]] = None,
content_type: Optional[str] = None,
) -> Any:
if content_type:
self.headers["Content-Type"] = content_type
try:
request_path = self.config.url + "/" + path
if not body:
request = http_method(
request_path,
timeout=self.config.timeout,
headers=self.headers,
)
elif isinstance(body, bytes):
request = http_method(
request_path,
timeout=self.config.timeout,
headers=self.headers,
data=body,
)
else:
request = http_method(
request_path,
timeout=self.config.timeout,
headers=self.headers,
data=json.dumps(body) if body else "" if body == "" else "null",
)
return self.__validate(request)
except requests.exceptions.Timeout as err:
raise MeilisearchTimeoutError(str(err)) from err
except requests.exceptions.ConnectionError as err:
raise MeilisearchCommunicationError(str(err)) from err @alallema doing this breaks several tests, but in ever case the test contains a type error sending Taking displayed attributes as an example, the fix is to change: - response = index.update_displayed_attributes(None)
+ response = index.reset_displayed_attributes() |
I just had another thought. I haven't tested they yet, but we can probably also simplify |
I made a slight tweak to allow things like def send_request(
self,
http_method: Callable,
path: str,
body: Optional[Union[Dict[str, Any], List[Dict[str, Any]], List[str], str]] = None,
content_type: Optional[str] = None,
) -> Any:
if content_type:
self.headers["Content-Type"] = content_type
try:
request_path = self.config.url + "/" + path
if body is None or body == "":
request = http_method(
request_path,
timeout=self.config.timeout,
headers=self.headers,
)
elif isinstance(body, bytes):
request = http_method(
request_path,
timeout=self.config.timeout,
headers=self.headers,
data=body,
)
else:
request = http_method(
request_path,
timeout=self.config.timeout,
headers=self.headers,
data=json.dumps(body),
)
return self.__validate(request)
except requests.exceptions.Timeout as err:
raise MeilisearchTimeoutError(str(err)) from err
except requests.exceptions.ConnectionError as err:
raise MeilisearchCommunicationError(str(err)) from err @dtomlinson91 if you want a PR feel fee to take it, if not I can do it. |
Happy for you to do it, you have done most of the work figuring out what needs changing after all 😁 |
Thanks @sanders41 for replying and your PR.
Indeed this is not the case.
The issue is that some of these methods: distinct_attribute, ranking rules, searchable attributes, and sortable attributes should be able to reset their parameters by sending |
We can inspect the |
One more thing, if I do find a solution what about the type errors? None of those methods I mentioned allow |
I solved the mock test issue with inspecting the |
You are so right 😕 ... Sorry to have made you change everything and thank you to find a good solution.
? |
Yes, changing the signature like you mentioned would fix the problem. Would you rather me add it to the PR I have open or do it in a separate one since it is a different issue? I'm good either way. |
@sanders41, if this is not a problem, two ERPs should be better since as you mentioned they are two different problems. |
765: Allow None for the body when updating settings r=alallema a=sanders41 # Pull Request ## Related issue Fixes the `None` typing issue discussed [here](#762 (comment)) ## What does this PR do? - Allows `None` to be sent in the `body` parameter for settings updates. ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: Paul Sanders <[email protected]> Co-authored-by: Amélie <[email protected]>
Description
Meilisearch is sending a body on a HTTP GET when using the client.
Meilisearch is running on GKE using image
getmeili/meilisearch:v1.1.1
. The instance is brand new with an empty indexaddresses
.Expected behavior
Meilisearch should send an empty body for a HTTP GET and return:
Current behavior
Meilisearch sits behind an external GCP HTTPS load balancer. The load balancer is opionated and rejects the request with a 400:
Load balancer log entry:
Response from request:
Screenshots or Logs
Debugging locally you can see there is a body being sent of
'null'
:Looking through previous issues it looks like #586 attempted to fix this, but it's still sending a body of
null
.Changing
meilisearch-python/meilisearch/_httprequests.py
Line 48 in f788922
Sends a body of
None
:and results in a successful request.
I'm happy to a raise a PR unless sending a body of
'null'
is intentional?The text was updated successfully, but these errors were encountered: