kubectl icon indicating copy to clipboard operation
kubectl copied to clipboard

CheckErr has trouble with handling wrapped errors

Open Somefive opened this issue 3 years ago • 11 comments

What would you like to be added:

Errors handled in CheckErr function are unable to be elegantly handled if they are wrapped.

https://github.com/kubernetes/kubectl/blob/18a5313a74f7d83f6b54377d72b421b5ebfa66c9/pkg/cmd/util/helpers.go#L152

In the following code, the apierrors.isInvalid checks the error with errors.As which can process the error chain but the type conversion below err.(*apierrors.StatusError) could lead to bad type conversion when encountering wrapped errors.

	case apierrors.IsInvalid(err):
		details := err.(*apierrors.StatusError).Status().Details
		s := "The request is invalid"
		if details == nil {
			handleErr(s, DefaultErrorExitCode)
			return
		}

Why is this needed:

I'm not sure if kubectl library should be able to handle the wrapped errors. We want to reuse the CheckErr function from kubectl in other projects where errors can be wrapped. This can be fixed by converting err into APIStatus first and then extract the Details. If this enhancement is permitted, I would be willing to make a PR for it.

Somefive avatar Apr 26 '22 07:04 Somefive

/triage accepted

NOTE: formatting errors since go version 1.13 should be handled with %w: https://stackoverflow.com/questions/61283248/format-errors-in-go-s-v-or-w

seans3 avatar Apr 27 '22 16:04 seans3

@Somefive thanks for opening issue. Triage accepted and you can work on that.

ardaguclu avatar May 13 '22 06:05 ardaguclu

@ardaguclu Thanks for the reply! I will work on it recently.

Somefive avatar May 14 '22 11:05 Somefive

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Aug 12 '22 12:08 k8s-triage-robot

/remove-lifecycle stale

Somefive avatar Aug 15 '22 02:08 Somefive

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Nov 13 '22 03:11 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Dec 13 '22 03:12 k8s-triage-robot

/remove-lifecycle rotten

Somefive avatar Dec 14 '22 05:12 Somefive

This issue has not been updated in over 1 year, and should be re-triaged.

You can:

  • Confirm that this issue is still relevant with /triage accepted (org members only)
  • Close this issue with /close

For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

/remove-triage accepted

k8s-triage-robot avatar Jan 19 '24 20:01 k8s-triage-robot

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Apr 18 '24 20:04 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar May 18 '24 20:05 k8s-triage-robot