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

Standardize modifies its input slice; the doc comment does not say so

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

@jihtsan is already working on this.

Since Oct 16, 2026.

  • #58 by @jihtsan — open

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
60/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
api, documentation

Research direction

Start with the doc comments on Standardize, Minimize and Format in the hujson package, and with how Parse keeps slices of b that Value.Standardize writes into. Run the repro in the issue to confirm that the input buffer changes on success. Done means the doc comment says that b may be modified, and the other two functions are covered too. Whether to copy the input instead is a maintainer decision, so check with them first.

Written by the indexing model from the issue text.

Description

hujson.Standardize(b) changes the caller's buffer b. The doc comment says the result is returned and that b is returned as is on error, but it does not say that b itself is modified on success. A caller that keeps b (for example to write the original file back unchanged) loses its comments.

Version: github.com/tailscale/hujson v0.0.0-20260727124030-b80ff77dac4f, Go 1.27.

Repro:

package main

import (
	"fmt"

	"github.com/tailscale/hujson"
)

func main() {
	in := []byte(`{"a": 1, /* c */ "b": 2,}`)
	before := string(in)
	out, err := hujson.Standardize(in)
	fmt.Printf("err=%v\nbefore=%q\nafter =%q\nout   =%q\n", err, before, string(in), string(out))
}

Output:

err=<nil>
before="{\"a\": 1, /* c */ \"b\": 2,}"
after ="{\"a\": 1,         \"b\": 2,}"
out   ="{\"a\": 1,         \"b\": 2 }"

The comment in in is replaced with spaces (the trailing comma in in is not). This is because Parse keeps slices of b and Value.Standardize writes into them before Pack.

Suggested fix, either:

  • document it: "Standardize may modify b; pass a copy if b is still needed", or
  • work on a copy: ast, err := Parse(bytes.Clone(b)).

The same likely applies to Minimize and Format.

Found in Ambit (https://github.com/craftsman-apps/ambit), which edits users' JSONC config files and must keep the original bytes; we now pass a copy.

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.