Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion actions/setup/js/close_entity_helpers.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const { buildWorkflowRunUrl } = require("./workflow_metadata_helpers.cjs");
const { isStagedMode } = require("./safe_output_helpers.cjs");
const { logStagedPreviewInfo } = require("./staged_preview.cjs");
const { validateTargetRepo, resolveTargetRepoConfig } = require("./repo_helpers.cjs");
const { ERR_API } = require("./error_codes.cjs");

/**
* @typedef {'issue' | 'pull_request'} EntityType
Expand Down Expand Up @@ -401,7 +402,7 @@ function createCloseEntityHandler(config, entityConfig, callbacks, githubClient)
);
// commentPosted stays false; close operation continues
} else {
throw commentError;
throw new Error(`${ERR_API}: Failed to add comment to ${entityConfig.displayName} #${entityNumber}: ${errorMsg}`, { cause: commentError });
}
Comment on lines 404 to 406
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.
}

Expand Down
5 changes: 3 additions & 2 deletions actions/setup/js/generate_safe_outputs_tools.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

const fs = require("fs");
const path = require("path");
const { ERR_CONFIG } = require("./error_codes.cjs");

async function main() {
const toolsSourcePath = process.env.GH_AW_SAFE_OUTPUTS_TOOLS_SOURCE_PATH || `${process.env.RUNNER_TEMP}/gh-aw/actions/safe_outputs_tools.json`;
Expand All @@ -46,7 +47,7 @@ async function main() {

// Load all source tools from the actions folder
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);
Comment on lines 49 to 52
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.
}
Expand All @@ -55,7 +56,7 @@ async function main() {

// Load config to determine which tools are enabled
if (!fs.existsSync(configPath)) {
const msg = `Error: Config file not found at: ${configPath}`;
const msg = `${ERR_CONFIG}: Config file not found at: ${configPath}`;
console.error(msg);
throw new Error(msg);
}
Expand Down
Loading