Skip to content

fix(USE-001): add standardized error codes to pr_review_buffer and set_issue_type handlers#41692

Merged
pelikhan merged 2 commits into
mainfrom
copilot/use-001-standardize-error-codes-again
Jun 26, 2026
Merged

fix(USE-001): add standardized error codes to pr_review_buffer and set_issue_type handlers#41692
pelikhan merged 2 commits into
mainfrom
copilot/use-001-standardize-error-codes-again

Conversation

Copilot AI commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Two safe-output handlers threw errors without standardized error code prefixes, causing USE-001 conformance failures in the daily safe-outputs checker.

Changes

  • actions/setup/js/pr_review_buffer.cjs — import ERR_API from error_codes.cjs; prefix the non-transient execution-state capture failure with ERR_API:
  • actions/setup/js/set_issue_type.cjs — import ERR_VALIDATION from error_codes.cjs; prefix the invalid confidence value throw with ERR_VALIDATION:
// before
throw new Error(`Failed to capture ${phase} PR review state for #${pullRequestNumber}: ...`);
throw new Error(`Invalid confidence ${JSON.stringify(intentMetadata.confidence)}. Expected one of: LOW, MEDIUM, HIGH.`);

// after
throw new Error(`${ERR_API}: Failed to capture ${phase} PR review state for #${pullRequestNumber}: ...`);
throw new Error(`${ERR_VALIDATION}: Invalid confidence ${JSON.stringify(intentMetadata.confidence)}. Expected one of: LOW, MEDIUM, HIGH.`);

Error codes follow the existing error_codes.cjs registry and the same import/prefix pattern already used across sibling handlers.

…t_issue_type handlers

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update handlers to use standardized error codes fix(USE-001): add standardized error codes to pr_review_buffer and set_issue_type handlers Jun 26, 2026
Copilot AI requested a review from pelikhan June 26, 2026 13:10
@pelikhan
pelikhan marked this pull request as ready for review June 26, 2026 13:15
Copilot AI review requested due to automatic review settings June 26, 2026 13:15
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates two actions/setup/js safe-output handlers to conform with USE-001 by ensuring thrown Error messages begin with standardized error-code prefixes from error_codes.cjs, matching the existing convention used across sibling handlers.

Changes:

  • pr_review_buffer.cjs: prefixes the non-transient “capture PR review state” exception with ERR_API:.
  • set_issue_type.cjs: prefixes the invalid intentMetadata.confidence exception with ERR_VALIDATION:.
Show a summary per file
File Description
actions/setup/js/pr_review_buffer.cjs Imports ERR_API and prefixes the non-transient execution-state capture throw to satisfy standardized error-code requirements.
actions/setup/js/set_issue_type.cjs Imports ERR_VALIDATION and prefixes the invalid-confidence throw to satisfy standardized error-code requirements.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Low

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #41692 does not have the 'implementation' label and has 0 new lines of code in business logic directories (threshold: 100).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review: APPROVE

Both changes are correct, minimal, and follow the established codebase pattern.

  • ERR_API is the right code for a non-transient GitHub REST API failure in fetchPullRequestReviewState.
  • ERR_VALIDATION is the right code for an invalid input value in the confidence switch.

Each file now has exactly one throw new Error and it is properly prefixed. No logic changes, no regression risk.

🔎 Code quality review by PR Code Quality Reviewer · 49.1 AIC · ⌖ 6.84 AIC · ⊞ 5.2K

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /diagnose and /tdd — commenting with observations (no blocking issues).

📋 Key Themes & Highlights

Key Themes

  • Correct fix, right error codes: ERR_API for a GitHub API failure in pr_review_buffer.cjs and ERR_VALIDATION for a bad input value in set_issue_type.cjs both match the error_codes.cjs taxonomy precisely.
  • Pattern consistency: Both changes faithfully follow the import-and-prefix pattern already used across sibling handlers — no surprises.
  • Missing regression tests: Neither changed error path is exercised by the existing test suites, so a future editor could silently drop a prefix and only the daily checker would notice. See inline comments for suggested tests.

Positive Highlights

  • ✅ Minimal, surgical changes — exactly 2 lines of production code altered per file
  • ✅ PR description is clear and self-contained with before/after snippets
  • ✅ Root cause (two non-compliant throws) is fully addressed, not just symptomised

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 42.9 AIC · ⌖ 7.16 AIC · ⊞ 6.5K

break;
default:
throw new Error(`Invalid confidence ${JSON.stringify(intentMetadata.confidence)}. Expected one of: LOW, MEDIUM, HIGH.`);
throw new Error(`${ERR_VALIDATION}: Invalid confidence ${JSON.stringify(intentMetadata.confidence)}. Expected one of: LOW, MEDIUM, HIGH.`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/tdd] This fixed error path has no regression test — a future refactor could silently drop the ERR_VALIDATION: prefix and the conformance checker would only catch it in the next daily run.

💡 Suggested test
it("throws ERR_VALIDATION for an unrecognised confidence value", () => {
  const intentMetadata = { confidence: "UNKNOWN" };
  expect(() => toRestIssueIntentMetadata(intentMetadata))
    .toThrow(/^ERR_VALIDATION:/);
});

This keeps the conformance guarantee self-verifying and avoids another USE-001 regression.

} catch (error) {
if (!isTransientError(error)) {
throw new Error(`Failed to capture ${phase} PR review state for #${pullRequestNumber}: ${getErrorMessage(error)} (non-transient)`, { cause: error });
throw new Error(`${ERR_API}: Failed to capture ${phase} PR review state for #${pullRequestNumber}: ${getErrorMessage(error)} (non-transient)`, { cause: error });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/tdd] The non-transient error branch (the one just fixed) isn't exercised by any test in pr_review_buffer.test.cjs — so the ERR_API: prefix could regress silently.

💡 Suggested test
it("fetchReviewStateBestEffort rethrows non-transient errors with ERR_API prefix", async () => {
  const nonTransientErr = new Error("quota exceeded");
  mockFetchPullRequestReviewState.mockRejectedValue(nonTransientErr);
  mockIsTransientError.mockReturnValue(false);

  await expect(buffer.fetchReviewStateBestEffort(repoParts, 123, "before"))
    .rejects.toThrow(/^ERR_API:/);
});

Pairs naturally with the existing transient-error path test to give full branch coverage.

@pelikhan
pelikhan merged commit 0cbd4d6 into main Jun 26, 2026
54 of 62 checks passed
@pelikhan
pelikhan deleted the copilot/use-001-standardize-error-codes-again branch June 26, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants