Skip to content

[WIP] Fix error handling in generate_git_patch.cjs for conformance#18869

Closed
Copilot wants to merge 1 commit intomainfrom
copilot/fix-error-codes-in-generate-git-patch
Closed

[WIP] Fix error handling in generate_git_patch.cjs for conformance#18869
Copilot wants to merge 1 commit intomainfrom
copilot/fix-error-codes-in-generate-git-patch

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Safe Outputs Conformance] USE-001: generate_git_patch.cjs throws errors without standardized error codes</issue_title>
<issue_description>### Conformance Check Failure

Check ID: USE-001
Severity: LOW
Category: Usability

Problem Description

actions/setup/js/generate_git_patch.cjs contains at least one throw new Error(…) statement that does not include a standardized error code (format: E###). The Safe Outputs specification and the codebase convention require that all error paths use codes in the E001E010 range (or defined ERROR_ / ERR_ constants) so that callers and operators can reliably identify and handle failure modes.

Without a standardized code, automated tooling and dashboards cannot distinguish this error from generic JavaScript exceptions, and users receive less actionable failure messages.

Affected Components

  • File: actions/setup/js/generate_git_patch.cjs
  • Location: The internal throw new Error("No remote refs available for merge-base calculation") inside Strategy 1 (full mode) — this error bubbles up through the outer catch block

Current Behavior

throw new Error("No remote refs available for merge-base calculation");

No E### code is present anywhere in the file.

Expected Behavior

Error messages should include a standardized code. For example:

throw new Error("E005: No remote refs available for merge-base calculation");

Or, using a constant:

const ERR_NO_REMOTE_REFS = "E005";
throw new Error(`\$\{ERR_NO_REMOTE_REFS}: No remote refs available for merge-base calculation`);

The exact code number should be chosen consistently with the codes used in sibling handlers (consult error_helpers.cjs or the specification's error code registry if one exists).

Remediation Steps

This task can be assigned to a Copilot coding agent with the following steps:

  1. Identify all throw new Error(…) and core.setFailed(…) calls in generate_git_patch.cjs that lack an E### prefix.
  2. Assign an appropriate standardized error code from the E001–E010 range (or define a new one if no suitable code exists — check other handlers for the current usage mapping).
  3. Prefix each error message with the code, e.g., "E005: No remote refs available …".
  4. Update or add unit tests that assert the error message contains the standardized code.

Verification

After remediation, verify the fix by running:

bash scripts/check-safe-outputs-conformance.sh

Check USE-001 should pass without errors. Also verify manually:

grep -E "E[0-9]{3}|ERROR_|ERR_" actions/setup/js/generate_git_patch.cjs

This should return at least one matching line.

References

  • Safe Outputs Specification: docs/src/content/docs/reference/safe-outputs-specification.md
  • Conformance Checker: scripts/check-safe-outputs-conformance.sh (lines 182–205)
  • Run ID: §22524821700
  • Date: 2026-02-28

Generated by Daily Safe Outputs Conformance Checker

  • expires on Mar 1, 2026, 4:54 PM UTC

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

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.

[Safe Outputs Conformance] USE-001: generate_git_patch.cjs throws errors without standardized error codes

2 participants