format: zero-valued window options and misplaced comments; WireGuard reserved error reports wrong length
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 38.2k
- Forks
- 4.6k
- Avg merge
- 19d 15h
- Merged PRs (30d)
- 1
Description
Operating system
macOS
System version
tahoe 26.6.2
Installation type
sing-box for macOS Graphical Client
If you are using a graphical client, please provide the version of the client.
1.14.0(1)
Version
Description
Three unrelated cosmetic defects in generated output, grouped in one report since none of them warrants an issue on its own. All reproducible on 1.14.0.
1. format writes zero-valued window options. Running sing-box format on a config with a hysteria2 outbound adds "stream_receive_window": 0 and "connection_receive_window": 0, which were never present. 0 means "do not override the default", so the emitted fields carry no meaning. They reappear on every run, so a formatted config never converges — each pass re-adds them after they are removed by hand. The same happens in the http_clients section. This looks like the MemoryBytes type not being compatible with omitempty.
2. format re-anchors comments to the wrong nesting level. A comment placed inside a nested object is emitted one level up, outside the block it belongs to, where the option it refers to does not exist. Comments are preserved, but they are anchored by position rather than by their enclosing block, which silently changes their meaning.
3. WireGuard reserved error reports the length of the destination array. Any invalid reserved array produces "required 3 bytes, got 3" regardless of what was supplied. The message is self-contradictory and gives no indication of what was wrong; the reported length appears to be taken from the fixed-size destination array rather than from the input. For comparison, the string form of reserved is validated on a different path and produces a clear message.
Reproduction
1 — zero-valued window options
Format any config containing a hysteria2 outbound:
sing-box format -w -c config.json
The two fields appear in the output. Remove them, run format again — they come back.
2 — misplaced comments
Given:
"reality": {
"enabled": true,
"handshake": {
"server": "example.com",
"server_port": 443
// "bind_interface": "eth0"
}
}
Run sing-box format -w -c config.json. The comment is emitted outside the handshake block.
3 — WireGuard reserved
{
"log": { "level": "error" },
"endpoints": [
{
"type": "wireguard",
"tag": "warp",
"mtu": 1420,
"address": ["172.16.0.2/32"],
"private_key": "<key>",
"peers": [
{
"address": "162.159.192.1",
"port": 2408,
"public_key": "<key>",
"allowed_ips": ["0.0.0.0/0"],
"reserved": [1, 2]
}
]
}
],
"outbounds": [{ "type": "direct", "tag": "direct" }],
"route": { "final": "direct" }
}
sing-box check -c config.json
Repeat with "reserved": [1, 2, 3, 4] — identical message. With [1, 2, 3] the config is valid.
Logs
reserved=[1,2] → FATAL[0000] initialize endpoint[0]: invalid reserved value for peer 0, required 3 bytes, got 3
reserved=[1,2,3,4] → FATAL[0000] initialize endpoint[0]: invalid reserved value for peer 0, required 3 bytes, got 3
reserved="AAA" → FATAL[0000] decode config at wg.json: endpoints[0].peers[0].reserved: illegal base64 data at input byte 0
reserved=[1,2,3] → (no output, config valid)
Supporter
- I am a sponsor
Integrity requirements
- I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
- I confirm that I have provided the server and client configuration files and process that can be reproduced locally, instead of a complicated client configuration file that has been stripped of sensitive data.
- I confirm that I have provided the simplest configuration that can be used to reproduce the error I reported, instead of depending on remote servers, TUN, graphical interface clients, or other closed-source software.
- I confirm that I have provided the complete configuration files and logs, rather than just providing parts I think are useful out of confidence in my own intelligence.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start by reproducing the three cases with sing-box format -w -c config.json and sing-box check -c config.json, then trace the formatter's handling of MemoryBytes, nested comments, and the WireGuard reserved validation path. Done means zero-valued window fields stay omitted, comments remain inside their enclosing object, and reserved-length errors report the supplied input length.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, networking, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100