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 referenced this pull request in cloudquery/plugin-pb-go Dec 1, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/avast/retry-go/v4](https://github.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://github.com/avast/retry-go/releases/tag/v4.5.1)

[Compare Source](https://github.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://github.com/dependabot) in [https://github.com/avast/retry-go/pull/95](https://github.com/avast/retry-go/pull/95)
-   add missing comma in the example by [@&#8203;spacewander](https://github.com/spacewander) in [https://github.com/avast/retry-go/pull/101](https://github.com/avast/retry-go/pull/101)
-   Add an example which shows err history by [@&#8203;avinassh](https://github.com/avinassh) in [https://github.com/avast/retry-go/pull/98](https://github.com/avast/retry-go/pull/98)
-   fix potential panic in IsRecoverable by [@&#8203;jalaziz](https://github.com/jalaziz) in [https://github.com/avast/retry-go/pull/104](https://github.com/avast/retry-go/pull/104)

#### New Contributors

-   [@&#8203;spacewander](https://github.com/spacewander) made their first contribution in [https://github.com/avast/retry-go/pull/101](https://github.com/avast/retry-go/pull/101)
-   [@&#8203;avinassh](https://github.com/avinassh) made their first contribution in [https://github.com/avast/retry-go/pull/98](https://github.com/avast/retry-go/pull/98)
-   [@&#8203;jalaziz](https://github.com/jalaziz) made their first contribution in [https://github.com/avast/retry-go/pull/104](https://github.com/avast/retry-go/pull/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://github.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.

2 participants