Skip to content

Fix: [Bug] Internal server error on /debug/registration-cache#3073

Draft
adamkasztenny wants to merge 2 commits into
juanfont:mainfrom
adamkasztenny:fix-issue-2714
Draft

Fix: [Bug] Internal server error on /debug/registration-cache#3073
adamkasztenny wants to merge 2 commits into
juanfont:mainfrom
adamkasztenny:fix-issue-2714

Conversation

@adamkasztenny
Copy link
Copy Markdown

@adamkasztenny adamkasztenny commented Feb 9, 2026

Summary

Fixes #2714: [Bug] Internal server error on /debug/registration-cache

AI Attribution

All code changes were made with OpenCode using OpenCode Zen Big Pickle.

Fixes issue juanfont#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 juanfont#2714.

Co-authored-by: OpenAI Code Generation Assistant
… endpoint

Adds a regression test to verify that the /debug/registration-cache endpoint
does not return 'json: unsupported type: chan *types.Node' error when there
are pending registrations. This test ensures the fix for issue juanfont#2714 remains
effective and prevents regressions.

The test simulates the scenario described in the issue by creating a registration
cache with RegisterNode structs containing channels, then verifies that the
DebugRegistrationCache method returns JSON-serializable data without exposing
the problematic channel types.

Co-authored-by: OpenAI Code Generation Assistant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Internal server error on /debug/registration-cache

1 participant