Skip to content

[plugin/opencode] 7 issues in plugins/open-code-review/opencode/open-code-review.ts (incl. timeoutMinutes never wired to process timeout) #702

Description

@waliean

OpenCodeReview Version

open-code-review v1.8.6 (1b193db) windows/amd64 built at: 2026-08-03T06:41:26Z

Operating System

Windows

Installation Method

npm (global)

LLM Provider

Other OpenAI-compatible endpoint

Bug Description

使用 OpenCodeReview v1.8.6(OCR 托管模式,DeepSeek-V4-Flash,自定义 OpenAI 兼容提供商)审查它自己的 OpenCode 插件 plugins/open-code-review/opencode/open-code-review.ts 时发现以下问题。所有发现均由 OCR 生成,带行级定位。

高危

H1. timeoutMinutes 未接入进程级超时(open-code-review.ts:307-310)
timeoutMinutes 被透传为 OCR 的 --timeout(schema 描述明确为"Per-file OCR timeout in minutes",即每文件超时),但调用 runOcr 时未传 timeoutMs,将使用默认的 15 分钟整进程超时。当评审总耗时超过 15 分钟、或用户将 timeoutMinutes 配置为大于 15 时,整个评审进程会在用户配置的每文件超时生效前就被强制终止——用户配置实际无法生效。

中危

M1. await client.app.log 失败会阻断插件注册(open-code-review.ts:273-279)
插件初始化直接 await client.app.log,若日志服务调用失败,会拒绝整个插件初始化 Promise,导致 ocr_review/ocr_health 工具无法注册。日志属于非关键路径,不应阻断核心功能。

M2. context.abort.aborted 假设 abort 信号必然存在(open-code-review.ts:335-337)
runOcr 将 signal 定义为可选(signal?: AbortSignal)并全程使用可选链保护,但此处直接访问 context.abort.aborted,若运行环境未提供 abort 信号会抛 TypeError。

M3. resume 未与 commit/from/to 互斥校验(open-code-review.ts:71-73)
buildReviewArgs 仅拦截了 preview+resumecommit+range 的互斥,未拦截 resumecommit/from/to 同时传入的情况。用户或 agent 可能构造出 OCR CLI 不支持的参数组合,只能看到底层命令错误。

M4. 子进程未 detached,超时/取消后留下孤儿进程(open-code-review.ts:149-151)
超时、取消或输出超限时仅对直接子进程发送 SIGTERM/SIGKILL,spawn 未使用 detached 创建独立进程组。OCR 评审过程中会启动 git、LLM 等后代进程,父进程被杀后这些进程可能成为孤儿继续运行,造成资源泄漏、文件锁或后续操作异常。

低危

L1. 空输出抛出误导性的 "invalid JSON" 错误(open-code-review.ts:241-246)
非 preview 模式下直接对 stdout 执行 JSON.parse,若 OCR 成功退出但没有输出(如无变更场景),JSON.parse('') 会抛 "Unexpected end of JSON input",最终显示为误导性的 "OpenCodeReview returned invalid JSON",掩盖了"无变更"这一正常情况。

L2. ReviewInput.repo 为死代码(open-code-review.ts:309)
repoReviewInput 中已定义,但未在 reviewArgs schema 中暴露,且调用处以 repo: cwd 强制覆盖用户传入值。该参数实际不可达,用户输入会被静默忽略。

Steps to Reproduce

使用 OpenCodeReview v1.8.6(OCR 托管模式,DeepSeek-V4-Flash,自定义 OpenAI 兼容提供商)审查它自己的 OpenCode 插件 plugins/open-code-review/opencode/open-code-review.ts 时发现以下问题。所有发现均由 OCR 生成,带行级定位。

环境

  • open-code-review v1.8.6(windows/amd64)
  • 通过 ocr review --audience agent --format json 审查(OCR 托管模式)

Expected Behavior

本来只想试验一下插件的。就拿它扫了一下自己,结果真扫出了。难说是扫出的bug不准确还是确实存在这些问题

Logs / Error Output

Additional Context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions