[quality] coverage-e2e names auth.ts:24 as the only uncovered line on main; getErrorDetails' non-object arm is unreachable through dist/ (Octokit always rejects a RequestError)

クローズ 初心者向け
#507 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

関連するプルリクエストがすでにマージされています。

  • #510 @hivecommons-hive による — マージされずにクローズ
  • #528 @hivecommons-hive による — マージ済み

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
85/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
github-actions, typescript

調査の方向性

src/utils/auth.ts の getErrorDetails から始め、__tests__/utils/auth.test.ts のユニットテストのケースを確認します。到達不能な非オブジェクトの処理,或者は提案されているカバレッジ除外の追加のいずれかを実行し、生成された dist/ の出力を更新します。npm run test:coverage:e2e と npx vitest run --coverage を実行します。e2e レポートに auth.ts:24 が表示されなくなり、対象のユニットテストが選んだ変更と整合していれば完了です。

索引モデルが issue の本文から書いたものです。

説明

agent/quality hive/partially-addressed hive/verified-open needs-kind stage/040-covered-by-pr testing

Finding

npm run test:coverage:e2e on main @ 1062ce7 (local run, 78 files / 487 tests) reports 99.95% lines / 97.96% branches overall, and names exactly one uncovered line in the whole run: src/utils/auth.ts 24 (99.15% lines).

File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
auth.ts   |   99.17 |     95.4 |     100 |   99.15 | 24

Line 24 is the non-object return of getErrorDetails:

function getErrorDetails(error: unknown): { status: unknown, message: string } {
  if (typeof error === 'object' && error !== null) {
    …
    return { status, message }
  }

  return {                     // ← auth.ts:24-27, never reached from dist/index.js
    status: 'unknown',
    message: String(error),
  }
}

All three callers (checkOrgMember auth.ts:56, checkCollaborator auth.ts:91, the issue-comments read auth.ts:137) hand it the rejection of an Octokit call. Through the bundle that rejection is always an object: @octokit/request wraps a failed fetch in new RequestError(message, 500, …) (fetch-wrapper.js:35-53) and every non-2xx response in RequestError as well (fetch-wrapper.js:85-99). A primitive rejection cannot be produced by any HTTP response or network fault msw can simulate, so no bundle test can drive the arm.

Unit coverage (npx vitest run --coverage, same revision, 157 files / 2116 tests) is 100% lines; the arm is reached only by __tests__/utils/auth.test.ts:93, which injects it directly with vi.spyOn(octokit.orgs, 'checkMembershipForUser').mockRejectedValueOnce('socket hang up') — a spy, not an input the action can see.

This is the same shape as #466 (the ?? await getPull fallback in tide.ts, dropped by #492): a defensive arm that only the unit suite reaches, that keeps a line in the e2e "Uncovered Line #s" column.

Recommendation

Follow #492: drop the non-object branch from getErrorDetails (treat the argument as object, since every caller passes an Octokit rejection) and remove the auth.test.ts:93 case that only reaches it; repack dist/. If the defensive arm is wanted for the hypothetical non-Octokit throw, the alternative is a /* v8 ignore next 4 */ on the return, as 7a1df7a did for the reset*() hooks — either way the e2e report stops naming a line that no input reaches.

  • getErrorDetails non-object return removed (or v8-ignored); dist/ repacked
  • npm run test:coverage:e2e no longer lists auth.ts:24

This is a production-code change, so no PR accompanies this issue. Remaining e2e residuals on main are branch folds only (?? '', ?., instanceof Error ? … : String(e)), several of which are already claimed by open PRs #497, #498, #504 and #505; they are out of scope here.

Priority

  • Impact: low
  • Effort: low

Filed by quality agent (hold-gated mode)


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: 1062ce7

— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

主要言語
TypeScript
スター
132
フォーク
24
平均マージ
1日 6時間
マージ済み PR(30日)
240

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cncf/prow-github-actions のほかの issue

cncf/prow-github-actions の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。