Skip to content

fix(bettergi): 单个 JS 脚本的 manifest.json 坏了不再让整个脚本列表拿不到 - #783

Open
ColinHouse wants to merge 4 commits into
AUTO-MAS-Project:devfrom
ColinHouse:fix/bettergi-js-manifest-tolerant
Open

ColinHouse wants to merge 4 commits into
AUTO-MAS-Project:devfrom
ColinHouse:fix/bettergi-js-manifest-tolerant

Conversation

@ColinHouse

@ColinHouse ColinHouse commented Sep 15, 2026

Copy link
Copy Markdown

摘要

  • User/JsScript/ 下任意一个脚本的 manifest.json 不是严格 JSON(例如尾逗号)时,GET /api/scripts/bettergi/js-scripts 整个返回 500,一条龙表单的 JS 脚本候选列表全部拿不到
  • list_js_scripts() 只用 manifest 取显示名,本就有「显示名退回目录名」的兜底;现在解析失败记一条 warning、显示名按目录名、继续列下一个,不静默吞错
  • 口径说明:refactor: 清理死代码与无意义兜底,修复预研发现的性能问题 #696 清理过一批无意义兜底,这里保留了日志、也不改变其他脚本的结果;如果更倾向把坏 manifest 的脚本整个从列表剔除而不是退回目录名,我可以改
  • 本地验证:未提交的用例(一个合法 manifest + 一个带尾逗号的 manifest)修复前直接抛 JSONDecodeError,修复后返回 [("AAA-Good", "好脚本"), ("BBB-Bad", "BBB-Bad")]pytest tests/task -k bettergi 31 passed;ruff(0.15.14)通过;pytest tests --collect-only 退出码 0

Closes #724

🤖 Generated with Claude Code

Sourcery 总结

改进 BetterGI JS 脚本发现机制,使其能够容忍单个无效的清单文件,而不会中断其余脚本列表的加载。

错误修复:

  • 防止单个格式错误的 JS 脚本清单导致整个 BetterGI 脚本列表加载失败。
  • 当脚本目录的清单无法解析时,回退使用脚本目录名称,同时保留警告以便诊断。
Original summary in English

Sourcery 摘要

让 BetterGI JS 脚本发现机制能够容忍无效的清单文件,同时保留其余脚本条目。

错误修复:

  • 防止格式错误的第三方 BetterGI JS 脚本清单导致整个脚本列表失效。
  • 当清单无法解析时,回退使用脚本目录名称,并记录警告。
Original summary in English

Sourcery 总结

允许在单个清单文件无效时继续发现 BetterGI JS 脚本。

错误修复:

  • 防止格式错误的第三方 BetterGI JS 清单导致整个脚本列表无法加载。
  • 当脚本清单无法解析时,回退使用脚本目录名称,同时记录警告以便诊断。
Original summary in English

Sourcery 总结

使 BetterGI JS 脚本发现机制能够容忍单个无效的清单文件。

错误修复:

  • 防止格式错误的 BetterGI JS 脚本清单导致其余脚本无法列出。
  • 当清单无法解析时,回退使用脚本目录名称,并记录警告。
Original summary in English

Summary by Sourcery

Make BetterGI JS script discovery resilient to individual invalid manifest files.

Bug Fixes:

  • Prevent a malformed BetterGI JS script manifest from preventing the remaining scripts from being listed.
  • Fall back to the script directory name and log a warning when a manifest cannot be parsed.

manifest.json 是玩家订阅或手放的第三方文件,list_js_scripts 只用它取显示名。
解析失败改为记一条 warning、显示名退回目录名并继续列下一个,接口不再 500。

Closes AUTO-MAS-Project#724

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Sep 15, 2026

Copy link
Copy Markdown
审查者指南(小型 PR 中折叠显示)

审查者指南

调整 BetterGI 一条龙 JS 脚本枚举逻辑:manifest.json 解析失败时记录警告、使用目录名作为显示名并继续枚举,从而避免单个第三方脚本损坏导致整个脚本列表接口失败;同时补充变更日志。

具备容错能力的 BetterGI JS 脚本枚举时序图

sequenceDiagram
    participant API as JS脚本列表API
    participant Enumerator as list_js_scripts
    participant Manifest as manifest.json
    participant Logger as BetterGILogger

    API->>Enumerator: list_js_scripts(root)
    loop 每个脚本目录
        Enumerator->>Manifest: read_file(manifest)
        alt manifest解析成功
            Manifest-->>Enumerator: data
            Enumerator->>Enumerator: 使用manifest.name或目录名
        else OSError或ValueError
            Manifest-->>Enumerator: 解析异常
            Enumerator->>Logger: warning(...)
            Enumerator->>Enumerator: 使用目录名作为显示名
        end
        Enumerator->>Enumerator: 继续枚举下一个脚本
    end
    Enumerator-->>API: 返回完整脚本列表
Loading

文件级变更

变更 详情 文件
使单个 JS 脚本的无效 manifest.json 不再阻断整个脚本列表生成。
  • 为 manifest 读取增加 OSError/ValueError 异常处理
  • 解析失败时记录 warning 并将显示名回退为目录名,继续处理其他脚本
  • 保持目录名去重和既有合法 manifest 的显示名逻辑不变
app/task/BetterGI/tools/one_dragon.py
补充该行为修复的变更日志。
  • 记录无效 manifest 不再导致一条龙 JS 脚本列表整体加载失败
changelog.d/fix-bettergi-js-manifest-tolerant.fix.md

可能关联的问题


提示和命令

与 Sourcery 交互

  • 触发新的审查: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 回复某条审查评论,请 Sourcery 根据该评论创建 issue。你也可以回复审查评论 @sourcery-ai issue,根据该评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在 pull request 中评论 @sourcery-ai title,随时重新生成标题。
  • 生成 pull request 摘要: 在 pull request 正文中任意位置写入 @sourcery-ai summary,即可在指定位置随时生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary,随时重新生成摘要。
  • 生成审查者指南: 在 pull request 中评论 @sourcery-ai guide,即可随时重新生成审查者指南。
  • 解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,这一功能会很有用。
  • 忽略所有 Sourcery 审查: 在 pull request 中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。如果你想从新的审查开始,这一功能尤其有用——别忘了评论 @sourcery-ai review 以触发新的审查!

自定义使用体验

访问你的控制面板以:

  • 启用或禁用审查功能,例如 Sourcery 生成的 pull request 摘要、审查者指南等。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

调整 BetterGI 一条龙 JS 脚本枚举逻辑:manifest.json 解析失败时记录警告、使用目录名作为显示名并继续枚举,从而避免单个第三方脚本损坏导致整个脚本列表接口失败;同时补充变更日志。

Sequence diagram for resilient BetterGI JS script enumeration

sequenceDiagram
    participant API as JS脚本列表API
    participant Enumerator as list_js_scripts
    participant Manifest as manifest.json
    participant Logger as BetterGILogger

    API->>Enumerator: list_js_scripts(root)
    loop 每个脚本目录
        Enumerator->>Manifest: read_file(manifest)
        alt manifest解析成功
            Manifest-->>Enumerator: data
            Enumerator->>Enumerator: 使用manifest.name或目录名
        else OSError或ValueError
            Manifest-->>Enumerator: 解析异常
            Enumerator->>Logger: warning(...)
            Enumerator->>Enumerator: 使用目录名作为显示名
        end
        Enumerator->>Enumerator: 继续枚举下一个脚本
    end
    Enumerator-->>API: 返回完整脚本列表
Loading

File-Level Changes

Change Details Files
使单个 JS 脚本的无效 manifest.json 不再阻断整个脚本列表生成。
  • 为 manifest 读取增加 OSError/ValueError 异常处理
  • 解析失败时记录 warning 并将显示名回退为目录名,继续处理其他脚本
  • 保持目录名去重和既有合法 manifest 的显示名逻辑不变
app/task/BetterGI/tools/one_dragon.py
补充该行为修复的变更日志。
  • 记录无效 manifest 不再导致一条龙 JS 脚本列表整体加载失败
changelog.d/fix-bettergi-js-manifest-tolerant.fix.md

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嘿——我已经审阅了你的更改,看起来很棒!

Sourcery 评估

已批准。


Sourcery 对开源项目免费提供服务——如果你喜欢我们的评审,请考虑分享它们 ✨
Original comment in English

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b87632c5b9

ℹ️ 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".

@@ -0,0 +1 @@
BetterGI专项 一条龙的 JS 脚本列表不再因为某个脚本的 manifest.json 格式有误而整体加载失败

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Describe only the user-visible symptom in the changelog

Rewrite this release-note sentence without naming manifest.json or its formatting as the implementation cause. The repository requires changelog fragments to omit internal details, state the observable symptom rather than its cause, and retain only a user-recognizable trigger; describing an anomalous third-party script causing the JS script list to fail would satisfy that requirement.

AGENTS.md reference: AGENTS.md:L39-L40

Useful? React with 👍 / 👎.

ColinHouse and others added 2 commits September 15, 2026 21:02
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@qiyinxi qiyinxi added the Sentry daily Sentry daily issues label Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Sentry daily Sentry daily issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants