-
Notifications
You must be signed in to change notification settings - Fork 340
fix: Avoid sending request body with GET (issue #318) #538
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
base: master
Are you sure you want to change the base?
Conversation
|
Could we avoid future regressions by adding a test that fails with the current code but passes with the proposed code? |
The test cases already reference this function. |
|
Adding tests for changes should be the default behavior; so, please avoid pushing back on requests to add tests. If the existing tests covered this case, they would have failed. They currently do not fail, so adding a test helps avoid regressions. |
This completely depends on where we are sending the HTTP network requests. The Apache Solr web backend still has backward compatibility to respond to HTTP GET requests with a request body. Howwever, it recommends using query parameters instead of sending data in the request body. This behavior may be removed in the future (I don't know), and Solr may completely stop reading the body of GET requests. |
Currently, it is not possible to test this because Solr still responds by reading data from the HTTP GET request body. |
|
Any thoughts? @acdha |
|
Looking at this, I'm thinking the answer might be to dub the next major release 4.x. I don't think there's a case where this would break on a version of Solr we still support but that would be a clear signal. We already have a bit of a breaking change it appears because in 11c881e the tests recognize that in the absence of I was already wondering about that because this commit makes me question whether I also noticed that the admin code is calling |
I'm also thinking the same, since there are some breaking changes (specially solr api response xml vs json).
If we've already decided to bump the major release, we can definitely consider this. It would really make sense and help avoid some repeated code.
+1 for this. We can create requests session inside |
0629857 to
1b44a58
Compare
| headers=headers, | ||
| auth=self.auth, | ||
| ) | ||
| return resp.json() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we call raise_for_status() here? Otherwise the caller doesn't have a simple way to tell whether the request was a success or error response unless we refactor the return signature to be status_code, decoded_json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@acdha The previous implementation also didn't have this feature.
Users can simply inspect the Solr JSON response’s status key if they want to know the HTTP status of the request.
|
This looks good, although I did have one question about error handling. |
| params=params, | ||
| headers=headers, | ||
| auth=self.auth, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ) | |
| ) | |
| resp.raise_for_status() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix our tests to properly handle this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cclauss will do.
e8e32df to
2dbb8a0
Compare
|
(PR Updated) Implement handling for bad HTTP responses from Solr and update tests |
Description
Fixes: Issue#318
This PR fixes an issue where parameters were being sent in the body of a GET request.
GETrequests should not contain a request body.The fix updates the request to pass parameters through the URL query string using
params=, which is what Solr expects.References
CoreAdmin Status API
https://solr.apache.org/guide/solr/9_9/configuration-guide/coreadmin-api.html#coreadmin-status
CoreAdmin Create API
https://solr.apache.org/guide/solr/9_9/configuration-guide/coreadmin-api.html#coreadmin-create
Collections DeleteStatus API
https://solr.apache.org/guide/solr/9_9/configuration-guide/collections-api.html#deletestatus