Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Untyped nil and nil containers are handled inconsistently across the API

Open
#120 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
go
Domain
api

Research direction

Start with the single-key Get and Array.Get in node.go (around lines 234-249), which already normalise untyped nil to Nil, and compare them with Find, multi-key Get/Has, Merge, Walk and the array growth in edit. The maintainers still need to pick the 1.0 rule for Array(nil) and Map(nil) before a patch can be written. Done means one agreed rule, applied across those paths, with a test for each case in the table.

Written by the indexing model from the issue text.

Description

bug

Problem

The library normalises an untyped Go nil to Nil (NilValue) at its entry points, but not elsewhere. Callers can therefore receive a raw nil Node or hit a panic depending on which API they use.

Normalised today (nil / missing → Nil):

Not normalised:

Case Current behaviour
Find(Array{nil}, ".[0]"), ".[]" returns []Node{nil} (raw nil leaks)
Map{"a": nil}.Get("a", "b"), Has("a", "b") panic (method call on nil interface)
Find(nil, ".") panic
Merge(nil, x), Merge(x, nil) panic
Merge(Map(nil), Map{...}) panic (assignment to nil map)
Walk over Map{"a": nil} nil children silently skipped
Edit(".a[2] = 1") on {"a": []} creates Array{nil, nil, 1} holes

Array(nil) / Map(nil) add a second flavour: JSON encodes them as null, YAML as [] / {}, and ToNode / ToAny / Clone turn them into empty non-nil containers.

Proposed direction

Pick one rule for 1.0 — likely "never hand out an untyped nil Node; treat it as Nil on read" — and apply it to Find / query Exec, multi-key Get / Has, Merge, Walk and the array growth in edit (fill holes with Nil). Decide separately whether Array(nil) / Map(nil) should encode as null or as empty containers.

Clone / CloneDeep already return Nil for an untyped nil as part of #102.

Dominant language
Go
Stars
7
Forks
2
Avg merge
11h 12m
Merged PRs (30d)
43

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mojatter/tree

All issues in mojatter/tree

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.