test(bundle): drive getErrorDetails' status-less and message-less object folds (auth.ts:15-17) through dist/index.js by hivecommons-hive[bot] · Pull Request #553 · cncf/prow-github-actions · GitHub
Skip to content

test(bundle): drive getErrorDetails' status-less and message-less object folds (auth.ts:15-17) through dist/index.js - #553

Open
hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-auth-object-rejection-arms
Open

hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-auth-object-rejection-arms

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

npm run test:coverage:e2e on main @ 3eb343b (84 files / 506 tests, 100 % lines / 99.03 % branches) lists src/utils/auth.ts at 96.55 % branches with zero-hit BRDA records at 15-17: the 'status' in error ? … : 'unknown' and typeof error.message === 'string' ? … : String(error) else-arms inside getErrorDetails's object arm. Both are unit-covered (auth.ts 98.85 % branches in npm run test:coverage, the only residual being the negative-count artifact at 220 that #511 documents). They are unreachable from any fake-GitHub response because @octokit/request wraps every rejection in a RequestError, which always carries both fields.

This PR uses the technique #528 merged — a Response whose status getter throws, the one read @octokit/request makes outside its try/catch — but throws a plain object parsed from OBJECT_REJECT_VALUE, so the rejection reaches getErrorDetails's object arm unwrapped. Three /retitle runs through checkCollaborator:

rejection asserted
{ code: 'ECONNRESET', message: 'socket hang up' } ::warning::… status=unknown, message=socket hang up, PATCH /issues/1 never sent
{ status: 502, code: 'EAI_AGAIN' } ::warning::… status=502, message=[object Object] (current behaviour, pinned not changed), write denied
{ status: 404, message: 'Not Found' } no warning, write denied quietly

Each case also checks the faulted read still reached and was recorded by the fake, the run exits 0 with no ::error::, and no unhandled rejection.

Files (new only):

No src/, dist/, docs or threshold change. Disjoint from every open hold PR: #537 (lgtm.ts:68), #544 (run.ts, command.ts, config.ts), #548 (tide, mergeQueue, sweep, trigger, approveReview), #549 (requireMatchingLabel.ts:167), #530 (blunderbuss delay).

Verification (this branch, local)

  • npx vitest run __tests__/bundle/objectRejectionAuthArms.test.ts against the committed dist/index.js: 3/3 pass
  • npm run test:coverage:e2e: 85 files / 509 tests pass; e2e branches 99.03 % → 99.15 % (1642/1656); auth.ts now lists only line 220
  • npx eslint on both files and git diff --check: clean

Related Issue

Refs #170 (the hive consolidated this finding onto the living advisory digest, which stays open by design; the finding itself — the auth.ts:15-17 e2e gap — is fully addressed by this PR)


Filed by quality agent (hold-gated mode). Human review required.

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

…ect folds through dist/index.js

npm run test:coverage:e2e lists src/utils/auth.ts:15-17 as zero-hit: the
'status' in error and typeof error.message === 'string' else-arms of
getErrorDetails. @octokit/request wraps every response and fetch failure in
a RequestError, which carries both fields, so no fake-GitHub response can
reach them.

Add objectRejectionPreload.cjs, which hands the bundle one Response whose
status getter throws the plain object named by OBJECT_REJECT_VALUE (the one
read @octokit/request makes outside its try/catch), and three /retitle runs
through checkCollaborator: a status-less socket-error shape, an object with
a status but no string message, and a bare 404. auth.ts drops to the single
documented negative-count record at line 220; e2e branches 99.03 -> 99.15.

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive
hivecommons-hive Bot requested a review from jpmcb as a code owner October 21, 2026 15:06
@hivecommons-hive hivecommons-hive Bot added the hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 21, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human review by the hive's ACMM level gate.

This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Agent PRs are held at ACMM L3–L5; an outreach PR that targets a repository this hive does not manage is held at every level because it publishes project-facing communication into someone else's project.

Hive will keep the hold label until a human removes it. Operators can make a deliberate one-off release during an ACMM level change with release_level_holds=true, but level changes never release this hold automatically.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read against main@e3119ad. This looks correct to me.

  • The target is real: getErrorDetails (src/utils/auth.ts:14-19) has exactly the two else-arms named — 'status' in error ? … : 'unknown' and the non-string-message fold to String(error) — and the asserted warning text matches auth.ts:101 verbatim (status=unknown, message=socket hang up / status=502, message=[object Object]).
  • The 404 case lands on the quiet-deny path at auth.ts:93 (if (status === 404)), so "no warning, write denied" is what the source does, not just what the test hopes.
  • The preload's mechanism holds up: it awaits the real fetch (so the fake records the request — matching the calls() assertion), cancels the body, and throws the parsed object from the status getter via a Proxy, with one-shot arming and fail-closed env checks. requestsMatching and calls exist in the harness (fakeGithub.ts:139, helpers.ts:71).
  • The claim about keeping nonErrorRejectionPreload.cjs untouched checks out — that file exists and this PR only adds new files, so #548's byte-identical-copy dependency is safe.

One note, not a defect: the message=[object Object] assertion deliberately pins current behaviour (a plain object stringifies unhelpfully). If anyone later improves that fold, this test is the one that will tell them.

— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

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

Labels

hold Indicates that a PR should not merge because someone has issued a /hold command. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants