1
0
mirror of https://github.com/juanfont/headscale.git synced 2026-02-23 13:50:36 +01:00
juanfont.headscale/hscontrol/state
Adam Kasztenny 2d754815ee Fix: internal server error on /debug/registration-cache endpoint
Fixes issue #2714 where the /debug/registration-cache endpoint would return
"internal server error" when there were pending registrations due to JSON
marshaling failure on "json: unsupported type: chan *types.Node".

The issue occurred because the RegisterNode struct contains a channel field
that cannot be serialized to JSON. The previous implementation was safe but
minimal, only returning basic cache metadata.

This enhancement:
- Safely exposes cache item count using zcache.ItemCount() method
- Exposes registration IDs without exposing the problematic RegisterNode structs
- Maintains JSON serializability by avoiding channels completely
- Provides more useful debug information while preserving safety

Changes:
- Enhanced DebugRegistrationCache() in hscontrol/state/debug.go to include
  item_count and registration_ids fields
- Added comprehensive tests to verify JSON marshaling works correctly
- Tests cover empty cache, single item, and multiple item scenarios

The endpoint now returns useful debug information without the JSON marshaling
error, resolving the issue reported in #2714.

Co-authored-by: OpenAI Code Generation Assistant
2026-02-08 18:56:19 -05:00
..
debug_registration_cache_test.go Fix: internal server error on /debug/registration-cache endpoint 2026-02-08 18:56:19 -05:00
debug_test.go hscontrol/state: make NodeStore batch configuration tunable (#2886) 2025-11-28 16:38:29 +01:00
debug.go Fix: internal server error on /debug/registration-cache endpoint 2026-02-08 18:56:19 -05:00
endpoint_test.go hscontrol/state: make NodeStore batch configuration tunable (#2886) 2025-11-28 16:38:29 +01:00
ephemeral_test.go all: upgrade to Go 1.26rc2 and modernize codebase 2026-02-08 12:35:23 +01:00
maprequest_test.go all: fix golangci-lint issues (#3064) 2026-02-06 21:45:32 +01:00
maprequest.go all: fix golangci-lint issues (#3064) 2026-02-06 21:45:32 +01:00
node_store_test.go all: upgrade to Go 1.26rc2 and modernize codebase 2026-02-08 12:35:23 +01:00
node_store.go all: fix golangci-lint issues (#3064) 2026-02-06 21:45:32 +01:00
state.go all: upgrade to Go 1.26rc2 and modernize codebase 2026-02-08 12:35:23 +01:00
tags.go hscontrol: use EmbedObject for node logging 2026-02-06 07:40:29 +01:00
test_helpers.go hscontrol/state: make NodeStore batch configuration tunable (#2886) 2025-11-28 16:38:29 +01:00