Skip to content

[quality] 14 commenter-auth catch arms (10 commands + auth.ts:181/210/217/224) are unreachable — only module mocks in unit tests keep them covered #386

Description

@hivecommons-hive

Finding

Fourteen catch arms that wrap the commenter-authorization probes are unreachable from the shipped bundle. The three probes they guard — checkOrgMember (src/utils/auth.ts:37-67), checkCollaborator (:77-104) and checkIssueComments (:116-142) — each wrap their whole body in try { … } catch { core.warning(…); return false }, so they never reject. The wrappers around them can only fire if the probe module itself is replaced, which is exactly how the unit suite reaches them:

wrapper file:line unit test that reaches it how
could not check commentor auth src/issueComment/close.ts:40, reopen.ts:37 __tests__/issueCommentTest/errorPaths.test.ts vi.mock('../../src/utils/auth', { spy: true }) + checkCollaborator.mockRejectedValueOnce
could not check commenter auth lock.ts:47, milestone.ts:40, src/labels/remove.ts:37 same / __tests__/label/errorPaths.test.ts same
could not check Commentor auth retitle.ts:45 same same
couldn ot check commentor Auth unassign.ts:58 same same
could not get authorized users assign.ts:61, cc.ts:58, uncc.ts:57 same getOrgCollabCommentUsers.mockRejectedValueOnce
could not get authorized user src/utils/auth.ts:181 (getOrgCollabCommentUsers) __tests__/utils/auth.test.ts makes core.warning throw (logger down)
error in checking org member / could not check collaborator / could not check issue comments src/utils/auth.ts:210, :217, :224 (checkCommenterAuth) __tests__/utils/auth.test.ts:263-278 same core.warning throw

errorPaths.test.ts:19 says so itself: "could not check auth" branches are only reachable when the helper rejects.

Evidence (main @ aa6a0f8, Node v26.10.0, vitest 5.0.3):

Why it matters for the test suite rather than tidiness: the unit report cannot distinguish "exercised by the bundle" from "exercised by a mock of the callee", so these arms keep a green line over error messages — including the misspelt couldn ot check commentor Auth — that no user can ever see, and the tests that cover them pin wording the action cannot emit.

Recommendation

One PR, one deliverable (the same mechanical edit at every site):

  • drop the try { … } catch (e) { throw new Error('could not check … auth: ' + e) } wrappers in close.ts, reopen.ts, lock.ts, milestone.ts, retitle.ts, unassign.ts, labels/remove.ts and the could not get authorized users wrappers in assign.ts, cc.ts, uncc.ts, calling the probe directly
  • drop the four wrappers inside src/utils/auth.ts (getOrgCollabCommentUsers:179-182, checkCommenterAuth:205-225)
  • delete the corresponding mockRejectedValueOnce cases in __tests__/issueCommentTest/errorPaths.test.ts, __tests__/label/errorPaths.test.ts and the logger down cases in __tests__/utils/auth.test.ts
  • npm run build && npm run pack so the dist/ drift gate passes

Alternative, if the wrappers are wanted as belt-and-braces: keep them but make the probes actually able to reject (rethrow non-404/302 statuses instead of return false), so the arms become reachable and the bundle suite can drive them. That is a behaviour change — today an API outage silently denies the command — and so also a maintainer call.

This touches production source, so it is not a PR this lane opens; it is filed for a maintainer. Companion to #366 (dead exports kept green by their own unit tests); kept separate because the fix sites do not overlap.

Priority

  • Impact: low
  • Effort: low

🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: 4948f6d

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

Activity

  1. added
    qualityCreated by Hive for agent-filed issue provenance
    testingCreated by Hive for agent-filed issue provenance
    agent/qualityCreated by Hive for agent-filed issue provenance
    on Oct 8, 2026
  2. hivecommons-hive commented on Oct 8, 2026

    @hivecommons-hive
    ContributorAuthor

    /kind cleanup


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

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

  3. added
    kind/cleanupCategorizes issue or PR as related to cleaning up code, process, or technical debt.
    and removed on Oct 8, 2026
  4. added
    hive/covered-by-prHive verified that an open PR references or claims this issue; still actionable until confirmed
    on Oct 11, 2026
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/covered-by-prHive verified that an open PR references or claims this issue; still actionable until confirmedhive/hosted-available-lke648397-260827-5q9tCreated by Hive for agent-filed issue provenancekind/cleanupCategorizes issue or PR as related to cleaning up code, process, or technical debt.qualityCreated 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