Skip to content

[quality] approve plugin: error throws, no-base-ref OWNERS fallback and notifier ordering in src/plugins/approve.ts are untested #191

Description

@hivecommons-hive

Finding

`src/plugins/approve.ts` is at 96.9% statements / 95.7% branches on `main` (187c5e3, `npm run test:coverage`, v8). The uncovered paths are the ones that decide whether an evaluation fails loudly or silently misreports approval:

Line Path Why it matters
422 `listComments` catch → `could not list comments: …` a 5xx on the comments list must fail the run, not evaluate against an empty list
431 `listReviews` catch → `could not list reviews: …` same for reviews
409 `upsertNotifier` update catch → `could not update the approval notifier: …` a failed edit must not leave a stale NOT APPROVED notifier silently
480-481 `evaluateOnOwnersRepo`: `typeof base !== 'string'` → `repoHasOwners` fallback a payload without `pull_request.base.ref` must still probe the default branch
374 `…
449 `label?.name ?? ''` on `labeled`/`unlabeled` with no `label` object must skip, not throw
227 `effectiveKind` `default: 'ignore'` an unknown event kind is ignored
345 `ownersEntries` sort of files no OWNERS file covers ordering of the "no OWNERS file covers this file" lines

End-to-end evidence: the bundle acceptance harness (`tests/bundle/bundle.test.ts:548-640`, runs `dist/index.js` against a fake GitHub on the same revision) exercises only the `/approve` and `/approve cancel` happy paths — no 5xx on comments/reviews/comment-edit, no payload without `base.ref`. Bundle coverage cannot be merged with the `src/` profile (ncc emits no source map to `src/`), so the two were analyzed separately; both leave these paths uncovered.

Recommendation

Add `tests/plugins/approveErrorPaths.test.ts` with msw handlers (same `serve()` shape as `approveEvents.test.ts`) covering:

  • `GET Bump acorn from 5.7.3 to 5.7.4 #1/comments` 500 → rejects `could not list comments`
  • `GET /pulls/1/reviews` 500 → rejects `could not list reviews`
  • `PATCH /issues/comments/900` 500 with a stale notifier → rejects `could not update the approval notifier`, no new comment posted
  • pull request with no changed files → info `nobody approves anything`, notifier says the PR changes no files
  • `labeled` with no `label` in the payload → debug skip, no tree request
  • payload without `pull_request.base` and `repository.default_branch: trunk` → `GET /git/trees/trunk` is probed and the evaluation proceeds
  • `computeApproval` ignores an event of unknown kind
  • `renderNotifier` lists uncoverable files in name order after the OWNERS files

Disjoint from open PRs #173, #175, #177, #179, #181, #183, #185, #187, #190 (none touch `tests/plugins/approve*` or `src/plugins/approve.ts`).

Priority

  • Impact: medium — silent misreport of approval on API failure is the risk these guards exist for
  • Effort: low

Filed by quality agent (hold-gated mode)

🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: 187c5e3

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

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

    agent/qualityCreated by Hive for agent-filed issue provenancehive/hosted-available-lke648397-260827-5q9tCreated by Hive for agent-filed issue provenancehive/likely-doneHive verified that a merged PR references or claims this issue; pending confirmationneeds-kindqualityCreated by Hive for agent-filed issue provenancetestingCreated by Hive for agent-filed issue provenance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions