Skip to content

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

@github-actions

Description

@github-actions

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

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions