Fix/legacy modpack null type - #6599
Conversation
|
维护者已经开始猜疑有 AI 特征的 PR 了:#6598 不过我先帮作者解释一下:
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e71bb584e5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| public void validate() throws JsonParseException { | ||
| if (manifest == null) | ||
| throw new JsonParseException("MinecraftInstanceConfiguration missing `manifest`"); | ||
| if (type == null) | ||
| throw new JsonParseException("MinecraftInstanceConfiguration missing `type`"); | ||
| } |
There was a problem hiding this comment.
Infer the provider before accepting a null type
When an existing modpack.cfg omits type, this relaxed validation lets finishModpackInstallingAsync proceed, but it then calls ModpackHelper.getUpdateTask before any of the modified installer checks run. The local-file path passes null to getProviderByType and reports the pack as unsupported, while the server-manifest path switches on null and throws an uncaught NullPointerException; consequently, the legacy configurations targeted by this change still cannot be updated. The provider must be inferred or normalized before these dispatch points rather than merely allowing type to remain null.
Useful? React with 👍 / 👎.
e71bb58 to
7c58b5a
Compare
3e0e463 to
da6266f
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da6266f7dc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (map.containsKey("manifestType") || (map.containsKey("files") && map.containsKey("minecraft"))) { | ||
| return "Curse"; |
There was a problem hiding this comment.
Check MCBBS signatures before classifying Curse manifests
When a legacy MCBBS modpack.cfg without type is loaded through readModpackConfiguration, its manifest is a Map containing both manifestType and addons. This first condition therefore returns Curse, so archive updates dispatch through CurseModpackProvider and fail with a mismatched-pack error, while launch-time MCBBS option injection is also skipped. Use signatures that distinguish the shared manifestType field, such as checking MCBBS-specific fields first.
Useful? React with 👍 / 👎.
| if (map.containsKey("addons")) { | ||
| return "MCBBS"; |
There was a problem hiding this comment.
Recognize server manifests before the shared addons field
A legacy server manifest contains both addons and fileApi, so this branch runs before the server check and returns MCBBS. Besides identifying the wrong format, that spelling does not match the registered provider name Mcbbs, causing local updates to report the pack as unsupported and server-manifest updates to reject it instead of accepting the inferred Server type.
Useful? React with 👍 / 👎.
da6266f to
0845bf7
Compare
0845bf7 to
b7b6513
Compare
概述
修复了由于旧版本 HMCL 或第三方工具导出的整合包配置文件
modpack.cfg中缺失type字段,导致在最新版本 HMCL 中更新整合包时抛出IllegalArgumentException或JsonParseException并中断更新的问题。根本原因
ModpackConfiguration.validate()强制要求type字段不能为null。在解析缺乏"type"键的旧版modpack.cfg时,校验失败导致反序列化抛出异常并落空。CurseInstallTask及其他整合包安装任务在比对提供商类型时没有检查type是否为null。在旧配置中type为null时,!"Curse".equals(null)被计算为true,从而误判并抛出IllegalArgumentException(“Instance is not a CurseForge modpack. Cannot update this instance.”)。主要修改
ModpackConfiguration.validate():移除了ModpackConfiguration.validate()中对type == null的强行抛错限制,允许旧版本整合包配置成功反序列化。CurseInstallTask、ModrinthInstallTask、McbbsModpackLocalInstallTask、McbbsModpackRemoteInstallTask、MultiMCModpackInstallTask、ServerModpackLocalInstallTask、ServerModpackRemoteInstallTask)中增加了config.getType() != null的前置检查。只有当type存在且明确与当前提供商不匹配时才抛出异常拦截;老整合包(type == null)将顺畅放行并在更新完成后自动写回包含type的规范新配置。