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

Gracefully degrade application failure error when deserializing #103

Merged

Conversation

drewhoskins-stripe
Copy link
Contributor

Description

As discussed in slack, our error handler raises when confronted with a user error that takes multiple arguments to instantiate.

This improves it by at least raising an error that links back to the original error (and still keeping the original backtrace)

Also log an error when this happens.

Test Plan

Unit:
rspec ./spec/unit/lib/temporal/workflow/errors_spec.rb
Integration, to check for regressions:

cd examples
./bin/worker
rspec ./spec/integration/await_workflow_result_spec.rb

@drewhoskins-stripe drewhoskins-stripe force-pushed the drewhoskins_serialization_fallback branch from 3dbd0a0 to aa531aa Compare September 28, 2021 20:55
@drewhoskins-stripe drewhoskins-stripe force-pushed the drewhoskins_serialization_fallback branch from aa531aa to 56558ca Compare September 28, 2021 20:56
@@ -0,0 +1,12 @@
# Simulates Temporal::Connection::Serializer::Failure
Fabricator(:application_failure, from: Temporal::Api::Failure::V1::Failure) do
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Can you please move this one over to fabricators/grpc and prefix with api_? Helps with distinguishing between domain and edge entities

application_failure_info do |attrs|
Temporal::Api::Failure::V1::ApplicationFailureInfo.new(
type: attrs[:error_class],
details: TestDeserializer.new.to_details_payloads(attrs[:message]),
Copy link
Contributor

Choose a reason for hiding this comment

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

This will fail when used in any other spec since TestDeserializer is only defined in a your new specs

Copy link
Contributor

Choose a reason for hiding this comment

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

Also since the fabricator is for a proto message it probably should not be concerned with error serialisation, but passed details for the error directly

Copy link
Contributor Author

@drewhoskins-stripe drewhoskins-stripe Sep 30, 2021

Choose a reason for hiding this comment

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

Good flag. As for the second suggestion, feels like reusing production methods rather than reimplementing them trumps strict dependencies here, to make tests more understandable and maintainable.

'Could not instantiate original error. Defaulting to StandardError.',
{
:original_error=>"ErrorWithTwoArgs",
:instantiation_error_message=> "wrong number of arguments (given 1, expected 2)",
Copy link
Contributor

Choose a reason for hiding this comment

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

Any specific reason for not using the new Hash syntax here (key: 'value')?

Copy link
Contributor

@antstorm antstorm left a comment

Choose a reason for hiding this comment

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

Looks good, thank you for the PR, Drew. I've noticed that it's missing a test case that uses an explicitly provided default error class.

It might be really useful to provide one of our error classes based on the context instead of the generic StandardError (which might be difficult to distinguish from other failures).

Let's add this in a follow up PR, but we should do this before bumping the version

@antstorm antstorm merged commit cccf233 into coinbase:master Oct 16, 2021
@antstorm antstorm added the sync pending Needs to be ported to cadence-ruby label Oct 21, 2021
calum-stripe pushed a commit to calum-stripe/temporal-ruby that referenced this pull request Nov 10, 2022
…oner/idle-metrics

Thread pool and poller metrics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sync pending Needs to be ported to cadence-ruby
Development

Successfully merging this pull request may close these issues.

None yet

2 participants