[Bug] Misleading error message while processing dns.extra_records_path #882

Closed
opened 2025-12-29 02:25:11 +01:00 by adam · 0 comments
Owner

Originally created by @nblock on GitHub (Dec 14, 2024).

Is this a support request?

  • This is not a support request

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Headscale prints an error message about unmarshalling records from dns.extra_records_path even though records are processed and streamed to nodes just fine.

Expected Behavior

Only print an error message when something went wrong permanently and cannot be recovered. Essentially transient errors happening while the file is written should be hidden. A user with the default log level has the impression that something is broken.

Steps To Reproduce

  1. Set dns.extra_records_path to some path
  2. Write to the file with: echo '[{"name":"grafana.myvpn.example.com","type":"A","value":"100.64.0.1"}]' | jq -cS > .headscale-dns/extra.json. Using this command triggers the error message reliably while headscale processes the changes correctly.
  3. Headscale logs:
2024-12-14T19:28:11+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=WRITE path=.headscale-dns/extra.json
2024-12-14T19:28:11+01:00 ERR ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:115 > reading extra records from path: .headscale-dns/extra.json error="unmarshalling records, content: \"\": unexpected end of JSON input"
2024-12-14T19:28:11+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=WRITE path=.headscale-dns/extra.json
2024-12-14T19:28:11+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:134 > extra records updated from path, count old: 1, new: 1 records=[{"Name":"grafana.myvpn.example.com","Type":"A","Value":"100.64.0.2"}]
2024-12-14T19:28:11+01:00 TRC ../runner/work/headscale/headscale/hscontrol/poll.go:644 > received stream update: StateFullUpdate  node=n1 node.id=1 omitPeers=false readOnly=false stream=true
2024-12-14T19:28:11+01:00 TRC ../runner/work/headscale/headscale/hscontrol/poll.go:644 > Sending Full MapResponse node=n1 node.id=1 omitPeers=false readOnly=false stream=true
2024-12-14T19:28:11+01:00 TRC finished writing mapresp to node mkey=mkey:94b730090613b46fe0f4a0a51518c2a585c63641a25a24ec419881be55015b0d node=n1 timeSpent=0.095543
2024-12-14T19:28:11+01:00 TRC ../runner/work/headscale/headscale/hscontrol/poll.go:644 > update sent node=n1 node.id=1 omitPeers=false readOnly=false stream=true

Environment

- OS: Arch
- Headscale version: 0.24.0-beta.1
- Tailscale version: -

Runtime environment

  • Headscale is behind a (reverse) proxy
  • Headscale runs in a container

Anything else?

No response

Originally created by @nblock on GitHub (Dec 14, 2024). ### Is this a support request? - [X] This is not a support request ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current Behavior Headscale prints an error message about unmarshalling records from `dns.extra_records_path` even though records are processed and streamed to nodes just fine. ### Expected Behavior Only print an error message when something went wrong permanently and cannot be recovered. Essentially transient errors happening while the file is written should be hidden. A user with the default log level has the impression that something is broken. ### Steps To Reproduce 1. Set `dns.extra_records_path` to some path 2. Write to the file with: `echo '[{"name":"grafana.myvpn.example.com","type":"A","value":"100.64.0.1"}]' | jq -cS > .headscale-dns/extra.json`. Using this command triggers the error message reliably while headscale processes the changes correctly. 4. Headscale logs: ``` 2024-12-14T19:28:11+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=WRITE path=.headscale-dns/extra.json 2024-12-14T19:28:11+01:00 ERR ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:115 > reading extra records from path: .headscale-dns/extra.json error="unmarshalling records, content: \"\": unexpected end of JSON input" 2024-12-14T19:28:11+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=WRITE path=.headscale-dns/extra.json 2024-12-14T19:28:11+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:134 > extra records updated from path, count old: 1, new: 1 records=[{"Name":"grafana.myvpn.example.com","Type":"A","Value":"100.64.0.2"}] 2024-12-14T19:28:11+01:00 TRC ../runner/work/headscale/headscale/hscontrol/poll.go:644 > received stream update: StateFullUpdate node=n1 node.id=1 omitPeers=false readOnly=false stream=true 2024-12-14T19:28:11+01:00 TRC ../runner/work/headscale/headscale/hscontrol/poll.go:644 > Sending Full MapResponse node=n1 node.id=1 omitPeers=false readOnly=false stream=true 2024-12-14T19:28:11+01:00 TRC finished writing mapresp to node mkey=mkey:94b730090613b46fe0f4a0a51518c2a585c63641a25a24ec419881be55015b0d node=n1 timeSpent=0.095543 2024-12-14T19:28:11+01:00 TRC ../runner/work/headscale/headscale/hscontrol/poll.go:644 > update sent node=n1 node.id=1 omitPeers=false readOnly=false stream=true ``` ### Environment ```markdown - OS: Arch - Headscale version: 0.24.0-beta.1 - Tailscale version: - ``` ### Runtime environment - [ ] Headscale is behind a (reverse) proxy - [ ] Headscale runs in a container ### Anything else? _No response_
adam added the bugDNS labels 2025-12-29 02:25:11 +01:00
adam closed this issue 2025-12-29 02:25:11 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#882