Change:
} storeTests := []jsonpathTest{ <del> {"plain", "hello jsonpath", nil, "hello jsonpath"}, {"recursive", "{..}", []int{1, 2, 3}, "[1 2 3]"}, {"filter", "{[?(@<5)]}", []int{2, 6, 3, 7}, "2 3"}, {"quote", `{"{"}`, nil, "{"}, {"union", "{[1,3,4]}", []int{0, 1, 2, 3, 4}, "1 3 4"}, {"array", "{[0:2]}", []string{"Monday", "Tudesday"}, "Monday Tudesday"}, {"variable", "hello {.Name}", storeData, "hello jsonpath"}, {"dict/", "{$.Labels.web/html}", storeData, "15"}, {"dict/", "{$.Employees.jason}", storeData, "manager"}, {"dict/", "{$.Employees.dan}", storeData, "clerk"}, {"dict-", "{.Labels.k8s-app}", storeData, "20"}, {"nest", "{.Bicycle[*].Color}", storeData, "red green"}, {"allarray", "{.Book[*].Author}", storeData, "Nigel Rees Evelyn Waugh Herman Melville"}, {"allfileds", "{.Bicycle.*}", storeData, "{red 19.95 true} {green 20.01 false}"}, {"recurfileds", "{..Price}", storeData, "8.95 12.99 8.99 19.95 20.01"}, </del> <ins> {"plain", "hello jsonpath", nil, "hello jsonpath", false}, {"recursive", "{..}", []int{1, 2, 3}, "[1 2 3]", false}, {"filter", "{[?(@<5)]}", []int{2, 6, 3, 7}, "2 3", false}, {"quote", `{"{"}`, nil, "{", false}, {"union", "{[1,3,4]}", []int{0, 1, 2, 3, 4}, "1 3 4", false}, {"array", "{[0:2]}", []string{"Monday", "Tudesday"}, "Monday Tudesday", false}, {"variable", "hello {.Name}", storeData, "hello jsonpath", false}, {"dict/", "{$.Labels.web/html}", storeData, "15", false}, {"dict/", "{$.Employees.jason}", storeData, "manager", false}, {"dict/", "{$.Employees.dan}", storeData, "clerk", false}, {"dict-", "{.Labels.k8s-app}", storeData, "20", false}, {"nest", "{.Bicycle[*].Color}", storeData, "red green", false}, {"allarray", "{.Book[*].Author}", storeData, "Nigel Rees Evelyn Waugh Herman Melville", false}, {"allfileds", "{.Bicycle.*}", storeData, "{red 19.95 true} {green 20.01 false}", false}, {"recurfileds", "{..Price}", storeData, "8.95 12.99 8.99 19.95 20.01", false}, </ins> {"lastarray", "{.Book[-1:]}", storeData, <del> "{Category: fiction, Author: Herman Melville, Title: Moby Dick, Price: 8.99}"}, </del> <ins> "{Category: fiction, Author: Herman Melville, Title: Moby Dick, Price: 8.99}", false}, </ins> {"recurarray", "{..Book[2]}", storeData, <del> "{Category: fiction, Author: Herman Melville, Title: Moby Dick, Price: 8.99}"}, {"bool", "{.Bicycle[?(@.IsNew==true)]}", storeData, "{red 19.95 true}"}, </del> <ins> "{Category: fiction, Author: Herman Melville, Title: Moby Dick, Price: 8.99}", false}, {"bool", "{.Bicycle[?(@.IsNew==true)]}", storeData, "{red 19.95 true}", false}, </ins> } testJSONPath(storeTests, false, t) missingKeyTests := []jsonpathTest{ <del> {"nonexistent field", "{.hello}", storeData, ""}, </del> <ins> {"nonexistent field", "{.hello}", storeData, "", false}, </ins> } testJSONPath(missingKeyTests, true, t) failStoreTests := []jsonpathTest{ <del> {"invalid identifier", "{hello}", storeData, "unrecognized identifier hello"}, {"nonexistent field", "{.hello}", storeData, "hello is not found"}, {"invalid array", "{.Labels[0]}", storeData, "map[string]int is not array or slice"}, {"invalid filter operator", "{.Book[?(@.Price<>10)]}", storeData, "unrecognized filter operator <>"}, {"redundent end", "{range .Labels.*}{@}{end}{end}", storeData, "not in range, nothing to end"}, </del> <ins> {"invalid identifier", "{hello}", storeData, "unrecognized identifier hello", false}, {"nonexistent field", "{.hello}", storeData, "hello is not found", false}, {"invalid array", "{.Labels[0]}", storeData, "map[string]int is not array or slice", false}, {"invalid filter operator", "{.Book[?(@.Price<>10)]}", storeData, "unrecognized filter operator <>", false}, {"redundent end", "{range .Labels.*}{@}{end}{end}", storeData, "not in range, nothing to end", false}, </ins> } testFailJSONPath(failStoreTests, t) }

Discussion:
On , will fail to evaluate a filter when the member does not exist: For instance, if I were to execute Where not all in that namespace had the annotation, this would fail with the error message: This is confusing as it leads me to think more than one item was selected, so while it is not technically incorrect the error message is misleading. I would furthermore expect to more gracefully handle this case -- a missing here means that the filter should fail, not error.
What do you mean by ? How is it different from ?
As in, don't add that item to the list of items on which the following access is made. When I do: And there is no annotation on , I just get nothing back -- no error, just nothing. Similarly, i would have expected the filtered expression to give me the for all of the pods that have an annotation with value . That, anyway is what I understand the JSONPath syntax to mean. When you write You are saying:
cc since you authored and I'm not sure how we want to fix this.
Taking a look now
it looks like you need to do this (note that the annotations portion is wrapped by ): I wrote a unit test and it worked as expected. PTAL!
I'm pretty sure that was a typo on my end but let me check -- do you have a reproducer script?
I see an entirely different error today... weird:
Ok so you have 1 object with annotations, and 1 without. Let me look into that case.
Let me add another annotation to
No difference if both have annotations:
Ok, I'll have to test using kubectl
I'm the Origin bundled but I don't think there are any patches on JSONPath there:
I'm able to reproduce in the unit test when 1 object has annotations and the other does not, if allowMissingKeys is true for the jsonpath parser.
I see. Let me know if I can be of more help.
I think I have a fix. PR coming soon.
Possible