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

feat(idempotency): preserve original error when wrapping into IdempotencyPersistenceLayerError #1552

Merged
merged 3 commits into from
Jun 26, 2023
Merged

feat(idempotency): preserve original error when wrapping into IdempotencyPersistenceLayerError #1552

merged 3 commits into from
Jun 26, 2023

Conversation

am29d
Copy link
Contributor

@am29d am29d commented Jun 26, 2023

Description of your changes

We use IdempotencyPersistenceLayerError to handle any unknown error that might occur during persistent operations. Examples are IAM permissions, connections, or other configuration issues. Therefore, we need to preserve the original error, so the developer can understand the cause.

With this PR we introduce a cause that enriches the original error.

I have also renamed the error file to align with the recent refactoring of the parameter utility.

Related issues, RFCs

Issue number: closes #1530

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my change is effective and works
  • The PR title follows the conventional commit semantics

Breaking change checklist

Is it a breaking change?: NO

  • I have documented the migration process
  • I have added, implemented necessary warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@am29d am29d requested a review from a team as a code owner June 26, 2023 13:37
@boring-cyborg boring-cyborg bot added idempotency This item relates to the Idempotency Utility tests PRs that add or change tests labels Jun 26, 2023
@pull-request-size pull-request-size bot added the size/M PR between 30-99 LOC label Jun 26, 2023
@github-actions github-actions bot added the feature PRs that introduce new features or minor changes label Jun 26, 2023
@am29d am29d requested a review from dreamorosi June 26, 2023 13:38
Copy link
Contributor

@dreamorosi dreamorosi Jun 26, 2023

Choose a reason for hiding this comment

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

Should we add the same cause related logic to the before, after, and onError phases of the middleware?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agh, good catch!

Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

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

Nicely done, I never thought we could add cause like this!

I left one question about whether or not we should add the same cause to the middy middleware.

Also I think sometime soon in a separate PR we should look into whether we can support #1361, I tried to print one of the errors with cause (logger.error('An error occurred', err);) thrown by us in this build and the cause doesn't show anywhere - I think we should support it if possible.

@am29d
Copy link
Contributor Author

am29d commented Jun 26, 2023

Nicely done, I never thought we could add cause like this!

The implementation is naive and since we did not have anything before, I am also open for discussion on alternatives.

Also I think sometime soon in a separate PR we should look into whether we can support #1361, I tried to print one of the errors with cause (logger.error('An error occurred', err);) thrown by us in this build and the cause doesn't show anywhere - I think we should support it if possible.

I can look into that in a separate PR.

@dreamorosi dreamorosi self-requested a review June 26, 2023 15:08
Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

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

LGTM!

@dreamorosi dreamorosi merged commit 866837d into aws-powertools:main Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature PRs that introduce new features or minor changes idempotency This item relates to the Idempotency Utility size/M PR between 30-99 LOC tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: makeHandlerIdempotent Masks Internal Errors
2 participants