fix(backend): tolerate invalid Fabric metadata#1823
Merged
Conversation
Contributor
Reviewer's GuideCentralizes Fabric mod metadata JSON parsing through a new lenient deserialization helper that retries parsing after stripping C0 control characters, and updates Fabric metadata loading from both jars and directories to use this helper. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
UNIkeEN
requested changes
Jul 5, 2026
Owner
|
@sourcery-ai review |
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
deserialize_lenient_jsonhelper silently alters input by stripping all C0 control characters; consider clarifying in the docstring or name that it is intended only for known-bad JSON (e.g., Fabric metadata) and avoid using it more broadly where that data loss might be surprising. strip_json_control_charscurrently removes all control characters including newlines and tabs; if you only intend to tolerate invalid characters inside strings, you may want to narrow the filter or add a comment explaining why removing formatting whitespace is acceptable here.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `deserialize_lenient_json` helper silently alters input by stripping all C0 control characters; consider clarifying in the docstring or name that it is intended only for known-bad JSON (e.g., Fabric metadata) and avoid using it more broadly where that data loss might be surprising.
- `strip_json_control_chars` currently removes all control characters including newlines and tabs; if you only intend to tolerate invalid characters inside strings, you may want to narrow the filter or add a comment explaining why removing formatting whitespace is acceptable here.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
UNIkeEN
approved these changes
Jul 7, 2026
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.
Checklist
This PR is a ..
Related Issues
fix #1764
Description
部分fabric模组元数据json未对字符串中\u{0000}~\u{001F}的控制字符转义,导致json解析失败。
修改后,当json解析失败后,尝试从json文件删除上述控制字符重新解析。
Additional Context
Summary by Sourcery
Relax Fabric mod metadata JSON parsing to tolerate invalid control characters in metadata files.
Bug Fixes:
Enhancements: