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

Parse rejects a final line comment with no trailing newline, which JWCC allows

Open Beginner friendly
#56 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
devtools

Research direction

Start in parse.go at consumeComment, which returns -1 when no closing newline exists, and at consumeExtra, which turns that into io.ErrUnexpectedEOF. Check the null// case in json_test.go, which currently expects that error and will change with the fix, and the Extra.format path that must keep Format idempotent. Done means {} // end and the JWCC example 123 // no final U+000A byte parse, U+2028/U+2029 handling is preserved, and the existing tests and fuzz targets pass.

Written by the indexing model from the issue text.

Description

Hi!

hujson.Parse rejects a line comment at the very end of the input when no \n follows it:

_, err := hujson.Parse([]byte("{} // end"))
// hujson: line 1, column 4: parsing comment: unexpected EOF

The JWCC text allows this. Since its update of 2021-07-20 it says "A line comment at the end of the file may omit the final '\n' byte", and gives 123 // no final U+000A byte as valid JWCC. That example fails the same way, at column 5.

  • consumeComment in parse.go looks for the closing \n and returns -1 when there is none, so consumeExtra reports io.ErrUnexpectedEOF.
  • The null// case in json_test.go (474be09) expects that error, so it would change along with the fix.

I have a small fix ready: consumeExtra treats the end of the input as the end of a line comment and keeps the U+2028 and U+2029 check from b80ff77, and Extra.format adds the missing newline, so Format stays idempotent (the null// fuzz seed caught that). The tests and both fuzz targets pass. Happy to open a PR if you'd take one.

I found this while running a set of JWCC test files through several parsers. Tested at b80ff77.

Best,

Simon

Dominant language
Go
Stars
876
Forks
35
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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 tailscale/hujson

All issues in tailscale/hujson

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.