fix(ui): handle invalid UTF-8 and NaN in layout JSON serialization#168
Open
Selene29 wants to merge 1 commit intoDeusData:mainfrom
Open
fix(ui): handle invalid UTF-8 and NaN in layout JSON serialization#168Selene29 wants to merge 1 commit intoDeusData:mainfrom
Selene29 wants to merge 1 commit intoDeusData:mainfrom
Conversation
The layout endpoint failed with "JSON serialization failed" for projects containing non-UTF-8 strings in node names or file paths. yyjson's default write mode rejects invalid UTF-8 (error code 7), causing the entire layout response to fail. - Use YYJSON_WRITE_ALLOW_INVALID_UNICODE for layout JSON serialization, matching the flag already used by the MCP JSON-RPC serializer - Sanitize NaN/Inf float values in node positions and sizes before serialization (force layout can produce these edge cases) - Use yyjson_mut_write_opts with error reporting so future failures log the actual yyjson error code and message
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
A single non-UTF-8 symbol in any node name or file path causes the entire
/api/layoutendpoint to fail with "JSON serialization failed", returning HTTP 500 for the whole project. yyjson's default write mode rejects invalid UTF-8 (error code 7), so one bad byte wrecks the entire graph visualization.YYJSON_WRITE_ALLOW_INVALID_UNICODEfor layout JSON serialization, matching the flag already used by the MCP JSON-RPC serializeryyjson_mut_write_optswith error reporting so future serialization failures log the actual yyjson error code and messageTest plan
scripts/test.sh SANITIZE=passes (2507 passed, 61 skipped — skips are network-dependent integration tests)