Skip to content

增强 GitHub Action 中 GitHub API 请求健壮性 #291

Closed

Description

@Terry-Mao

需求

增强 GitHub Action 中 PR review 发布阶段的 GitHub API 请求健壮性。

建议

  • 对 DNS 或连接失败增加有限重试和指数退避。
  • 为 urlopen(..., timeout=...) 设置超时,避免网络异常时无限等待。
  • 仅在最终失败后退出,并保留已生成的 review artifact。

相关位置

  • .github/scripts/post_pr_review.py:51
  • .github/scripts/post_pr_review.py:496

Activity

  1. added
    area:workflowGitHub workflows and Python automation scripts
    enhancementNew feature or request
    repro:unknownThere is not enough information to estimate reproducibility
    triagedIssue has been reviewed and categorized
    on Oct 3, 2026
  2. github-actions commented on Oct 3, 2026

    @github-actions
    Contributor

    初步分诊

    类型:增强请求(workflow / GitHub API 请求健壮性)
    可复现性:unknown
    置信度:high

    结论

    .github/scripts/post_pr_review.py 的 github_api_response() 调用 urllib.request.urlopen(request) 时未设置 timeout,且异常处理仅捕获 urllib.error.HTTPError。DNS 解析失败、连接被拒/重置等网络异常会以未捕获的 urllib.error.URLError(或 TimeoutError)抛出,导致发布 PR review 的步骤立即失败;当前也没有重试或指数退避,无法在最终失败前容忍瞬时网络抖动。issue 引用的 496 行附近的 request_json(url, token, payload) 调用同样落到这条无超时、无重试的路径。

    建议

    • 为 urlopen 显式传入 timeout,避免网络异常时无限等待。
    • 对 DNS / 连接类瞬时失败增加有限重试与指数退避。
    • 重试耗尽后再退出;workflow 已通过 if: always() 上传 pr-worktree/review.json 等产物,请确认新的失败路径不会阻断该上传。

    相关文件

    • .github/scripts/post_pr_review.py
    • .github/workflows/review-pr.yml

    重复检查

    对比 dedupe_candidates.json 后,未发现 2 个及以上符合相似度门槛的重复 issue;最接近的 #288 关注的是 review workflow 整体运行时长超时,与本 issue 的网络请求健壮性不是同一问题,因此不标记 duplicate。

    标签

    enhancement, area:workflow, repro:unknown, triaged

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

    area:workflowGitHub workflows and Python automation scriptsenhancementNew feature or requestrepro:unknownThere is not enough information to estimate reproducibilitytriagedIssue has been reviewed and categorized

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions