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

Return HTTP 400 if content-md5 does not match #596

Closed
wants to merge 1 commit into from

Conversation

kellymclaughlin
Copy link
Contributor

On PUT, Riak currently will not return HTTP 400 if the Content-MD5 header and the MD5 of the body do not match. S3 does. It does return the correct MD5 as the ETAG, and some clients do recognize this and throw and exception. Returning HTTP 400 is easy. Making sure we properly garbage collect the 'bad' version is a bit trickier.

kellymclaughlin added a commit that referenced this pull request Jul 17, 2013
Fixes #596

Respect content-md5 headers on object uploads and return HTTP 400 with
appropriate error body when it does not match the calculated digest of
the object body. Also refactor the handling of content-md5 headers for
multipart part uploads so that is matches the handling for normal
object uploads.
@reiddraper
Copy link
Contributor Author

thoughts on making a separate TODO for writing a client-test for this?

@kellymclaughlin
Copy link
Contributor

thoughts on making a separate TODO for writing a client-test for this?

yeah good idea

@reiddraper
Copy link
Contributor Author

I'm reviewing locally merged or rebased with #622.

@reiddraper
Copy link
Contributor Author

  • Eunit and eqc tests pass
  • Pulse tests
  • Client and int tests pass
  • Dialyzer output clean
  • Xref output clean
  • riak_test tests pass

@reiddraper
Copy link
Contributor Author

client test passed, but int-test is failing. Will see if this is happening on develop too.

kellymclaughlin added a commit that referenced this pull request Jul 24, 2013
Fixes #596

Respect content-md5 headers on object uploads and return HTTP 400 with
appropriate error body when it does not match the calculated digest of
the object body. Also refactor the handling of content-md5 headers for
multipart part uploads so that is matches the handling for normal
object uploads.
@kellymclaughlin
Copy link
Contributor

client test passed, but int-test is failing. Will see if this is happening on develop too.

Addressed by a352742 and bc7bccf.

@kellymclaughlin
Copy link
Contributor

Rebased from latest develop

@reiddraper
Copy link
Contributor Author

Addressed by a352742 and bc7bccf.

Nice, that fixes the test-int problems.

@reiddraper reiddraper mentioned this pull request Jul 24, 2013
@@ -70,6 +71,22 @@ api_error({error, Reason}, RD, Ctx) ->
error_response(StatusCode, _Code, _Message, RD, Ctx) ->
{{halt, StatusCode}, RD, Ctx}.

%% @TODO Figure out how this should actually be formatted
Copy link
Contributor

Choose a reason for hiding this comment

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

In what way are we not sure how this should be formatted? Does this just mean we haven't tested that this makes clients throw the correct exception? If so, that can be part of #624.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh right, this is also just for OpenStack, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, they don't have any documentation I have found about expected error responses or error formatting and I haven't had a chance to manually determine it yet so punting for now.

@reiddraper
Copy link
Contributor Author

+1, great work

Fixes #596

Respect content-md5 headers on object uploads and return HTTP 400 with
appropriate error body when it does not match the calculated digest of
the object body. Also refactor the handling of content-md5 headers for
multipart part uploads so that is matches the handling for normal
object uploads.
@reiddraper
Copy link
Contributor Author

See #624 to track testing of this PR.

_ = maybe_update_manifest_with_confirmation(ManiPid, Manifest),
_ = riak_cs_gc:gc_active_manifests(Bucket, Key, RiakPid),
gen_fsm:reply(From, {error, invalid_digest}),
{stop, invalid_digest, State};
Copy link
Contributor

Choose a reason for hiding this comment

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

This causes a crash report to be printed. I might argue that this is still a 'normal' exit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants