Skip to content

Fix SetPath writes through typed nil maps - #99

Open
00200200 wants to merge 1 commit into
bitly:masterfrom
00200200:codex/setpath-nil-maps
Open

00200200 wants to merge 1 commit into
bitly:masterfrom
00200200:codex/setpath-nil-maps

Conversation

@00200200

Copy link
Copy Markdown

SetPath panics with assignment to entry in nil map when a typed nil map[string]interface{} is stored at the root or encountered along a path. For example, after j.SetPath(nil, map[string]interface{}(nil)), j.SetPath([]string{"value"}, "set") panics instead of creating the object.

Treat nil maps like other values that need an object allocated before descending or writing. Regression cases cover root maps, nested maps, intermediate path creation, retrieval, encoding, and preservation of sibling keys.

Validation (Go 1.27.1, macOS arm64):

  • Before the fix, the root and child regression cases independently panic.
  • After the fix, targeted SetPath/path tests and go test -race -count=1 ./... pass.
  • go vet ./..., gofmt, and git diff --check pass.

AI disclosure: prepared and checked with OpenAI Codex. No personal human review was performed. Validation is local and automated; no live services or downstream applications were tested.

@qodo-for-bitly

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Great, no issues found!

Qodo reviewed your code and found no material issues that require review
Tip of the day
💡 Did you know, you can tweak Display settings with a live preview to see your comment before it ships

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗


Powered by Qodo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant