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 the prefix requirement in ListObjects #3005

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alyssaxu333
Copy link
Contributor

Summary

ListObjects request without prefix will throw 400 error. But Amazon S3 ListObject request doesn't require prefix, it will list all objects in the bucket. Fix the request requirement.

Testing Done

Unit test

* @throws RestServiceException
*/
public static NamedBlobPath parse(RestRequest restRequest) throws RestServiceException {
restRequest.setArg(InternalKeys.REST_METHOD, restRequest.getRestMethod());
Copy link
Contributor

Choose a reason for hiding this comment

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

May I know why do we need this extra internal header?
If you want the rest method you can directly get it right?
If you want to know which request is S3 request, you can use isS3Request(restRequest).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So in parseS3, I added a check for whether it's a listObject request or not. To determine if it's a listObject request, the rest method should be "Get" and the blob uri should be s3/account/container. But parseS3(String path, Map<String, Object> args) doesn't have rest method passed into it. I was thinking about changing it to parseS3(RestRequest restRequest) or adding rest method header in args beforehand. Changing signatures seems to be a bigger change thus I chose the second way. Pls let me know which way do you think is better, or if there's other ways to revise it that I didn't consider.

Copy link
Contributor

Choose a reason for hiding this comment

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

Changing signatures seem to be cleaner approach. But, if it involves changing too many files, may be adding the Rest method to args is also okay.

I think we could also add Rest method to args in FrontendRestRequestService#preProcessAndRouteRequest so that it is available to all requests.

@@ -522,6 +527,11 @@ public static final class InternalKeys {
* content-length header
*/
public static final String CONTENT_RANGE_LENGTH = KEY_PREFIX + "content-range-length";

/**
* Boolean field set to "true" if this is a S3 request.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Looks like copy-paste typo

* @throws RestServiceException
*/
public static NamedBlobPath parse(RestRequest restRequest) throws RestServiceException {
restRequest.setArg(InternalKeys.REST_METHOD, restRequest.getRestMethod());
Copy link
Contributor

Choose a reason for hiding this comment

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

Changing signatures seem to be cleaner approach. But, if it involves changing too many files, may be adding the Rest method to args is also okay.

I think we could also add Rest method to args in FrontendRestRequestService#preProcessAndRouteRequest so that it is available to all requests.

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.

4 participants