diff --git a/pkg/apiserver/registry/datapackaging/package_storage_client.go b/pkg/apiserver/registry/datapackaging/package_storage_client.go index 9cf2e2486..e6cb0643a 100644 --- a/pkg/apiserver/registry/datapackaging/package_storage_client.go +++ b/pkg/apiserver/registry/datapackaging/package_storage_client.go @@ -152,10 +152,14 @@ func (t PackageTranslator) ToExternalWatcher(intObjWatcher watch.Interface, fiel } func (t PackageTranslator) ToExternalError(err error) error { - statusErr := err.(*errors.StatusError) + statusErr, isStatusError := err.(*errors.StatusError) + if !isStatusError { + return err + } - if statusErr.ErrStatus.Details.Kind == "internalpackages" && statusErr.ErrStatus.Details.Group == internalpkgingv1alpha1.SchemeGroupVersion.Group { - packageName, err := t.ToExternalName(statusErr.ErrStatus.Details.Name) + details := statusErr.ErrStatus.Details + if details.Kind == "internalpackages" && details.Group == internalpkgingv1alpha1.SchemeGroupVersion.Group { + packageName, err := t.ToExternalName(details.Name) if err != nil { return err }