-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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 empty table when sorting on nonexistent field #119460
base: master
Are you sure you want to change the base?
Fix empty table when sorting on nonexistent field #119460
Conversation
Welcome @philip-peterson! |
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Hi @philip-peterson. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: philip-peterson The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
@@ -406,15 +430,17 @@ func NewTableSorter(table *metav1.Table, field string) (*TableSorter, error) { | |||
} | |||
} | |||
|
|||
if len(table.Rows) > 0 && !fieldFoundOnce { | |||
return nil, fmt.Errorf("couldn't find any field with path %q in the list of objects", field) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I guess the original intention was to fail if the field was not found in the list of objects.
I wonder if anyone (other than kubectl) is depending on this behavior.
I'm wondering if we should preserve the behavior of NewTableSorter, as-is, and handle the error properly in kubectl.
If this error is returned, why isn't it being printed anywhere? 🤔
It looks like the problem is here:
printer.PrintObj(info.Object, w) |
It's not checking if PrintObj
returns an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brianpursley Nice find! Do you think that is what the behavior should be? (The bug report ticket said it should fall back to the behavior where no filter was applied.)
What type of PR is this?
/kind bug
What this PR does / why we need it:
If a the JSONPath specified by
kubectl get ... --sort-by [json-path]
matches no rows, falls back to displaying every row and a warning indicating that no row matched, instead of zero rows.Which issue(s) this PR fixes:
Fixes kubernetes/kubectl#1343
Special notes for your reviewer:
I wasn't too sure about the
errors.Is
vserrors.As
stuff. It seems to work but not super clear on if it's correct.Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: