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

Field errors are persisted in between calls #26

Closed
splittingred opened this issue Sep 26, 2017 · 0 comments
Closed

Field errors are persisted in between calls #26

splittingred opened this issue Sep 26, 2017 · 0 comments
Assignees
Labels

Comments

@splittingred
Copy link
Member

Have been able to confirm this by creating an RPC method that adds field errors depending on incoming value:

context 'with multiple calls, where the first returns an error, the second doesnt' do
  it 'should not raise a Gruf::Client::Error the second time', run_thing_server: true do
    client = build_client
    expect do
      client.call(:GetContextualFieldErrorFail, id: 1)
    end.to raise_error(Gruf::Client::Error)

    expect do
      client.call(:GetContextualFieldErrorFail, id: 2)
    end.to_not raise_error(Gruf::Client::Error)
  end
end

It will throw an error currently:

expected no Gruf::Client::Error, got #<Gruf::Client::Error: Gruf::Client::Error> with backtrace:

This seems to be due to @error being set memoized on the service class, and not reset in-between calls. This was designed in order to support the add_field_error method without having to pass around an error object. A simple fix is just to unset the @error attribute at the end of every call.

@splittingred splittingred self-assigned this Sep 26, 2017
splittingred added a commit to splittingred/gruf that referenced this issue Sep 26, 2017
splittingred added a commit that referenced this issue Sep 26, 2017
#26: Fix issue with field errors being persisted between calls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant