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

fix potential panic in IsRecoverable #104

Merged
merged 1 commit into from Nov 14, 2023

Conversation

jalaziz
Copy link
Contributor

@jalaziz jalaziz commented Nov 14, 2023

The way unrecoverableError wraps an error can lead to potential panics. In IsRecoverable, an unrecoverableError is passed to errors.Is without an embedded error. This is problematic because any error type that implements the Is interface and expects to be able to call Error() will trigger a panic due to the embedded error being nil.

To fix this, we can implement Error() on unrecoverableError and handle the case where the embedded error is nil.

The way `unrecoverableError` wraps an error can lead to potential
panics. In `IsRecoverable`, an `unrecoverableError` is passed to
`errors.Is` without an embedded error. This is problematic because any
error type that implements the `Is` interface and expects to be able to
call `Error()` will trigger a panic due to the embedded error being
`nil`.

To fix this, we can implement `Error()` on `unrecoverableError` and
handle the case where the embedded error is nil.
@jalaziz
Copy link
Contributor Author

jalaziz commented Nov 14, 2023

This is very problematic because there is no simple workaround for this issue. unrecoverableError is currently a misbehaving error.

@JaSei
Copy link
Collaborator

JaSei commented Nov 14, 2023

Thanks for your PR.

@JaSei JaSei merged commit 64083c1 into avast:master Nov 14, 2023
10 of 11 checks passed
@jalaziz jalaziz deleted the fix-unrecoverable-error-panic branch November 14, 2023 17:28
kodiakhq bot pushed a commit to cloudquery/plugin-pb-go that referenced this pull request Dec 1, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/avast/retry-go/v4](https://togithub.com/avast/retry-go) | require | patch | `v4.5.0` -> `v4.5.1` |

---

### ⚠ Dependency Lookup Warnings ⚠

Warnings were logged while processing this repo. Please check the Dependency Dashboard for more information.

---

### Release Notes

<details>
<summary>avast/retry-go (github.com/avast/retry-go/v4)</summary>

### [`v4.5.1`](https://togithub.com/avast/retry-go/releases/tag/v4.5.1)

[Compare Source](https://togithub.com/avast/retry-go/compare/4.5.0...4.5.1)

#### What's Changed

-   Bump github.com/stretchr/testify from 1.8.2 to 1.8.4 by [@&#8203;dependabot](https://togithub.com/dependabot) in [avast/retry-go#95
-   add missing comma in the example by [@&#8203;spacewander](https://togithub.com/spacewander) in [avast/retry-go#101
-   Add an example which shows err history by [@&#8203;avinassh](https://togithub.com/avinassh) in [avast/retry-go#98
-   fix potential panic in IsRecoverable by [@&#8203;jalaziz](https://togithub.com/jalaziz) in [avast/retry-go#104

#### New Contributors

-   [@&#8203;spacewander](https://togithub.com/spacewander) made their first contribution in [avast/retry-go#101
-   [@&#8203;avinassh](https://togithub.com/avinassh) made their first contribution in [avast/retry-go#98
-   [@&#8203;jalaziz](https://togithub.com/jalaziz) made their first contribution in [avast/retry-go#104

**Full Changelog**: avast/retry-go@4.5.0...v4.5.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on the first day of the month" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMDkuNCIsInVwZGF0ZWRJblZlciI6IjM2LjEwOS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
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.

None yet

2 participants