query: Read null like jq in key steps, comparisons and contains()
Maintainers usually reply within 1 day
@mojatter is already working on this.
Since Oct 25, 2026.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start with MapQuery.Exec, ArrayQuery.Exec, ContainsQuery.Exec, and wordValue in parser.go, then trace how NilValue is handled by comparisons and selectors. Reproduce the listed cases and check count() and type() behavior when choosing whether null steps return no result or Nil. Done means the null cases match the expected jq results and the changed behavior is covered by tests.
Written by the indexing model from the issue text.
Description
Reading null disagrees with jq in three places:
| Input | Query | tree | jq |
|---|---|---|---|
{"a":null} |
.a.b |
cannot index array with "b" |
null |
{"a":[null]} |
.a[0].b |
cannot index array with "b" |
null |
{"a":[null,{"x":1}]} |
.a[.x == 1] |
cannot index array with "x" |
{"x":1} |
[{"age":1},null] |
.sort(.age) |
cannot index array with "age" |
[null,{"age":1}] |
{"a":[[null],[1]]} |
.a[.[0] != null] |
[[null],[1]] |
[1] |
{"a":[[null],[1]]} |
.a[.[0] == null] |
nothing | [null] |
[null,1] |
.contains("") |
true |
— (no empty string in the array) |
- Key and index steps:
MapQuery.ExecandArrayQuery.Execreturn an error for every value type,NilValueincluded. - Comparisons: the parser has no
nullliteral (wordValueinparser.goonly knowstrue,falseand numbers), sonullbecomes the string"null", andNilValue.Comparetreats!=against it as true and==as false. contains(): elements are compared byValue().String(), andNilValue.String()is"", so a null element matchescontains("").
Since #150, a Go nil element reads as null too, so arrays with holes left by growth hit all of these as well, e.g. any selector over .a after .a[2] = 1.
Fix:
- Return no result (or
Nil) fromMapQuery.Exec/ArrayQuery.Execon null, and decide which, since a selector treats "no result" andnullthe same butcount()andtype()do not. - Parse
nullasNilinwordValue, and decide what= nullmeans in an edit RHS (it is parsed as YAML there and already givesNil). - Skip null elements in
ContainsQuery.Exec, or compare by type.
This changes observable behaviour: queries that errored on null start succeeding, and comparisons with null flip.
- Dominant language
- Go
- Stars
- 7
- Forks
- 2
- Avg merge
- 11h 12m
- Merged PRs (30d)
- 43
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mojatter/tree
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
Similar issues
-
[flaky test] TestValidatorCommitterDropsEmptyStatusBatch: submits to the mock VC before its stream is registeredPossibly taken @liran-funaro claimed this today. Opencoordinator flaky-test race-condition testing
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
hyperledger/fabric-x-committer#876 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
garethgeorge/backrest#1426 ·
Maintainers usually reply within 1 day
-
enhancement nav-pilot
Difficulty 2/5 Half a day Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
valkey-io/valkey-operator#549 · 1 comment ·
Maintainers usually reply within 3 days
-
kind/features
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
TencentBlueKing/bk-nodemgr#3804 ·
Maintainers usually reply within 1 day