Skip to content

fix(USE-001): add standardized ERR_* error codes to two non-conformant handlers#26315

Merged
pelikhan merged 3 commits intomainfrom
copilot/use-001-add-standardized-error-codes
Apr 14, 2026
Merged

fix(USE-001): add standardized ERR_* error codes to two non-conformant handlers#26315
pelikhan merged 3 commits intomainfrom
copilot/use-001-add-standardized-error-codes

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

Two handlers were throwing bare errors without the ERR_* prefixes required by error_codes.cjs, breaking structured logging and alerting rules (conformance check USE-001).

Changes

  • close_entity_helpers.cjs: Added ERR_API import; replaced bare throw commentError with a wrapped error that includes the ERR_API prefix and preserves the original as { cause: commentError } for stack trace retention.
  • generate_safe_outputs_tools.cjs: Added ERR_CONFIG import; prefixed both throw new Error(msg) calls (missing source tools file, missing config file) with ERR_CONFIG.
// Before
throw commentError;
throw new Error(`Error: Source tools file not found at: ${toolsSourcePath}`);

// After
throw new Error(`${ERR_API}: Failed to add comment to ${entityConfig.displayName} #${entityNumber}: ${errorMsg}`, { cause: commentError });
throw new Error(`${ERR_CONFIG}: Source tools file not found at: ${toolsSourcePath}`);

Copilot AI and others added 2 commits April 14, 2026 22:46
Copilot AI changed the title [WIP] Add standardized error codes to two handlers fix(USE-001): add standardized ERR_* error codes to two non-conformant handlers Apr 14, 2026
Copilot AI requested a review from pelikhan April 14, 2026 22:47
@pelikhan pelikhan marked this pull request as ready for review April 14, 2026 22:48
Copilot AI review requested due to automatic review settings April 14, 2026 22:48
@pelikhan pelikhan merged commit d37c7c6 into main Apr 14, 2026
54 checks passed
@pelikhan pelikhan deleted the copilot/use-001-add-standardized-error-codes branch April 14, 2026 22:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 brings two safe-output setup/handler scripts into USE-001 conformance by ensuring thrown errors include standardized ERR_* prefixes for structured logging.

Changes:

  • Added ERR_CONFIG to generate_safe_outputs_tools.cjs and prefixed missing-file error messages.
  • Added ERR_API to close_entity_helpers.cjs and replaced a bare rethrow with a wrapped Error that includes an error code and preserves the original error via cause.
Show a summary per file
File Description
actions/setup/js/generate_safe_outputs_tools.cjs Prefixes missing source/config file errors with ERR_CONFIG for standardized error codes.
actions/setup/js/close_entity_helpers.cjs Wraps comment-posting failures with an ERR_API-prefixed error and attaches the original error as cause.

Copilot's findings

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment on lines 49 to 52
if (!fs.existsSync(toolsSourcePath)) {
const msg = `Error: Source tools file not found at: ${toolsSourcePath}`;
const msg = `${ERR_CONFIG}: Source tools file not found at: ${toolsSourcePath}`;
console.error(msg);
throw new Error(msg);
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

This change introduces a standardized ERR_CONFIG prefix for missing-file errors, but the existing unit tests for the missing source/config file cases only assert that the script throws (they don’t assert the error message starts with ERR_CONFIG:). Adding an assertion for the thrown error message would prevent regressions in USE-001 conformance.

Copilot uses AI. Check for mistakes.
Comment on lines 404 to 406
} else {
throw commentError;
throw new Error(`${ERR_API}: Failed to add comment to ${entityConfig.displayName} #${entityNumber}: ${errorMsg}`, { cause: commentError });
}
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

The new wrapped throw (with ${ERR_API}: ... and { cause: commentError }) isn’t covered by tests. Since this file already has a Vitest suite, add a unit test that forces callbacks.addComment to reject when continueOnCommentError is false and assert the returned error message includes the ERR_API: prefix (and optionally that the thrown Error has the expected cause).

Copilot uses AI. Check for mistakes.
@github-actions github-actions Bot mentioned this pull request Apr 14, 2026
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: Two handlers missing standardized error codes (ERR_* prefix)

3 participants