Fix: [Bug] Internal server error on /debug/registration-cache#3073
Draft
adamkasztenny wants to merge 2 commits into
Draft
Fix: [Bug] Internal server error on /debug/registration-cache#3073adamkasztenny wants to merge 2 commits into
adamkasztenny wants to merge 2 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.