Skip to content

refactor: replace pkg/errors with standard errors package#2658

Open
space-aditya wants to merge 1 commit intomicrosoft:mainfrom
space-aditya:feature/phase-one-replace-to-standar-error-package
Open

refactor: replace pkg/errors with standard errors package#2658
space-aditya wants to merge 1 commit intomicrosoft:mainfrom
space-aditya:feature/phase-one-replace-to-standar-error-package

Conversation

@space-aditya
Copy link
Copy Markdown

No description provided.

Signed-off-by: Aditya <jaiswal.aditya.deelip@gmail.com>

Signed-off-by: Aditya <jaiswal.aditya.deelip@gmail.com>
@space-aditya space-aditya requested a review from a team as a code owner April 1, 2026 18:33
@space-aditya
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@space-aditya
Copy link
Copy Markdown
Author

space-aditya commented Apr 1, 2026

Hey @jterry75, @dcantah @helsaawy!
How have you been doing?

I was working on a package deprecation for https://github.com/containerd/containerd
and as it's core dep, i had to update the errors package to use the native golang package instead of a third party one ("errors" instead of "github.com/pkg/errors").

this is a first in a series of PRs i want to raise for the same.
Please let me know if i should proceed, or if any complications exists, i'll be happy to take care of those.

Thank you.

@space-aditya
Copy link
Copy Markdown
Author

@anmaxvl @thaJeztah could you help with this please

Hey @jterry75, @dcantah @helsaawy! How have you been doing?

I was working on a package deprecation for https://github.com/containerd/containerd and as it's core dep, i had to update the errors package to use the native golang package instead of a third party one ("errors" instead of "github.com/pkg/errors").

this is a first in a series of PRs i want to raise for the same. Please let me know if i should proceed, or if any complications exists, i'll be happy to take care of those.

Thank you.

Comment on lines -58 to -70
// TODO: update implementation to use go1.13 style errors with `errors.As` and co.

// StackTracer is an interface originating (but not exported) from the
// github.com/pkg/errors package. It defines something which can return a stack
// trace.
type StackTracer interface {
StackTrace() errors.StackTrace
}

// BaseStackTrace gets the earliest errors.StackTrace in the given error's cause
// stack. This will be the stack trace which reaches closest to the error's
// actual origin. It returns nil if no stack trace is found in the cause stack.
func BaseStackTrace(e error) errors.StackTrace {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FWIW; this means we'd lose the stack-traces?

Probably relevant for this context; while in many cases stdlib will work, there's situations where it doesn't provide the same functionality; we recently got communication open with the pkg/ folks, and the pkg/errors repository has been un-archived so that it can be used for situations where stdlib is not sufficient;

cc @tonistiigi

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

stack traces won't be lost, it can be retrieved with the runtime/debug, debug.Stack() method.
but yes, that would require a middleware or manual changes

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

on the positive side, this would also mean that only panic'able errors should occur, atleast that's what i see emerging as a pattern out of this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe @tonistiigi can provide more context; I know that BuildKit is a heavy user of pkg/errors (and stdlib errors didn't fit the bill there), but I don't know the full context where stdlib lacked the features needed.

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