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

Handle siblings with no content type #1

Closed
wants to merge 2 commits into from

Conversation

dtykocki
Copy link

@dtykocki dtykocki commented Sep 23, 2016

@spreedly/product-dev

When a deletion conflict occurs, attempting to read the `data` property
of an `RObject` results in an exception being generated. The exception is
raised because `riak-client` is unable to find a serializer for an object
that is marked for deletion (read: no content_type). Since we cannot directly
access `data`, inspect all of the siblings and reject the items having a `nil`
`content_type`. This allows for conflict resolution to continue for the remaining
siblings.
@mrezentes
Copy link

This issue has already been identified in the basho's repo. This PR attempts to address it. I think that this PR is better especially since it has tests.
I am good with these changes. I would like a second set of 👀 @rwdaigle

Copy link

@rwdaigle rwdaigle left a comment

Choose a reason for hiding this comment

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

If this is a port of the existing PR out for ripple, why does it look so different?

Also, just by way of background, is there a better way to get our Ripple client up to date than to further diverge from the original? Seems like there's going to have to be a day of reckoning at some point in the future?

@@ -8,10 +8,10 @@ module Conflict
end

describe 'calling the lambda returned by .to_proc' do
let(:sibling_1) { stub(:data => { '_type' => 'User' } ) }
let(:sibling_2) { stub(:data => { '_type' => 'User' } ) }
let(:sibling_1) { stub(:data => { '_type' => 'User' }, :content_type => 'application/json') }
Copy link

@rwdaigle rwdaigle Sep 23, 2016

Choose a reason for hiding this comment

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

Can we add this new content-type based test as a separate new test vs. overwriting a previous test (which implies it's not backwards compatible)?

Copy link
Author

Choose a reason for hiding this comment

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

Hmm.. The content type was added to get the two existing resolver specs to pass since we expect objects to respond to content_type. All RObject instances respond to content_type so I believe this should be a safe change.

Choose a reason for hiding this comment

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

@dtykocki I guess if we're ensuring backwards compatibility, you'd like to see that all existing tests can pass. Modifying the existing tests for such a fundamental library like Ripple makes me a little nervous.

Copy link
Author

Choose a reason for hiding this comment

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

Agreed - making this change makes me just as nervous 😨.

I can add a respond_to? check to the rejection block before checking the content type. Since the stubs don't respond to content_type, we'll never attempt the nil check. The existing specs should still pass then.

@dtykocki
Copy link
Author

If this is a port of the existing PR out for ripple, why does it look so different?

I have a few issues with the existing PR and it won't solve the issue were running into:

  1. Calling robject.data.nil? will generate the same exception we're trying to workaround. When accessing the data property of a deleted object, riak-client attempts to find a serializer based on the object's content_type property. For deleted objects, there is no content type.
  2. No specs for the change.
  3. I prefer to filter out objects without a content type instead of hardcode them to 'application/json`.

@dtykocki
Copy link
Author

is there a better way to get our Ripple client up to date than to further diverge from the original?

I'd like to think there's a better way. I assumed since we have a fork that we gave up trying merge upstream. Also, the last release was back in 2012 so there's a chance it's not really maintained anymore?

@dtykocki
Copy link
Author

From what I gather, we depend heavily on ripple. Is it worth considering taking over maintenance of project? Totally not trying to add more to the current workload, just a thought 😄 .

@dtykocki dtykocki force-pushed the handle-siblings-with-no-content-type branch from 2f0006f to d11eebb Compare September 26, 2016 13:26
@dtykocki dtykocki closed this Apr 16, 2018
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.

3 participants