Skip to content

fix: add standardized error codes (USE-001) to four safe-output handlers#22620

Merged
pelikhan merged 3 commits intomainfrom
copilot/use-001-fix-standardized-error-codes
Mar 24, 2026
Merged

fix: add standardized error codes (USE-001) to four safe-output handlers#22620
pelikhan merged 3 commits intomainfrom
copilot/use-001-fix-standardized-error-codes

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 24, 2026

Three handlers (create_discussion, create_issue, push_signed_commits) were failing the USE-001: Error Code Standardization conformance check — their error paths lacked standardized error code prefixes from the Safe Outputs spec. qmd_index.cjs had the same issue and is fixed here too.

All error paths now use named constants from the shared error_codes.cjs helper instead of hardcoded E00X strings.

Changes

  • create_issue.cjs / create_discussion.cjs — prefix close-older-key validation throw with ERR_VALIDATION
  • push_signed_commits.cjs — prefix OID resolution failure and GraphQL mutation no-OID response with ERR_API
  • qmd_index.cjs — prefix missing env var and missing SDK errors with ERR_CONFIG; prefix invalid repo slug and insufficient-results check with ERR_VALIDATION

Before / After

// Before
throw new Error(`close-older-key "${rawCloseOlderKey}" is invalid: ...`);
throw new Error(`Could not resolve OID for new branch ${branch}`);

// After
const { ERR_VALIDATION } = require("./error_codes.cjs");
throw new Error(`${ERR_VALIDATION}: close-older-key "${rawCloseOlderKey}" is invalid: ...`);

const { ERR_API } = require("./error_codes.cjs");
throw new Error(`${ERR_API}: Could not resolve OID for new branch ${branch}`);

Verified with bash scripts/check-safe-outputs-conformance.shUSE-001 now passes across all handlers.


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

…ate_issue, push_signed_commits, qmd_index handlers

Prefix all throw/setFailed error messages with the appropriate standardized
error codes per the Safe Outputs specification (E001-E010):

- create_issue.cjs: close-older-key validation → E001 (INVALID_SCHEMA)
- create_discussion.cjs: close-older-key validation → E001 (INVALID_SCHEMA)
- push_signed_commits.cjs: OID resolution and GraphQL mutation failures → E007 (API_ERROR)
- qmd_index.cjs: missing env var / missing SDK / invalid repo slug → E001 (INVALID_SCHEMA),
  insufficient results count → E002 (LIMIT_EXCEEDED)

Verified with: bash scripts/check-safe-outputs-conformance.sh
All four handlers now pass USE-001 without errors.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/ba18c7e8-4980-43c7-9f07-198bb0825def
@github-actions github-actions bot mentioned this pull request Mar 24, 2026
Copilot AI changed the title [WIP] Fix missing standardized error codes in handlers fix: add standardized error codes (USE-001) to four safe-output handlers Mar 24, 2026
Copilot AI requested a review from pelikhan March 24, 2026 06:28
@pelikhan pelikhan marked this pull request as ready for review March 24, 2026 11:18
Copilot AI review requested due to automatic review settings March 24, 2026 11:18
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

Adds standardized Safe Outputs error-code prefixes to previously non-conformant handlers/scripts to satisfy the USE-001 conformance check.

Changes:

  • Prefix close-older-key validation errors with E001 in create_issue and create_discussion.
  • Prefix signed-commit OID failure paths with E007 in push_signed_commits.
  • Prefix several core.setFailed(...) paths with E001/E002 in qmd_index.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
actions/setup/js/qmd_index.cjs Adds E00X: prefixes to setup-script failure messages (env var / missing SDK / invalid slug / min results).
actions/setup/js/push_signed_commits.cjs Adds E007: prefixes to OID resolution and GraphQL missing-OID error paths.
actions/setup/js/create_issue.cjs Adds E001: prefix to invalid close-older-key configuration error.
actions/setup/js/create_discussion.cjs Adds E001: prefix to invalid close-older-key configuration error.

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

const fileCount = fs.readdirSync(searchDir).length;
if (fileCount < minCount) {
core.setFailed(`qmd search "${collectionName}" returned ${fileCount} results, minimum is ${minCount}`);
core.setFailed(`E002: qmd search "${collectionName}" returned ${fileCount} results, minimum is ${minCount}`);
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

E002 is used elsewhere in this repo to mean “max limit exceeded” (e.g., dispatch_repository returns E002: Max count ... reached), matching the Safe Outputs catalog’s LIMIT_EXCEEDED. Here the condition is fileCount < minCount (minimum not met), so the emitted E002 is misleading/inconsistent. Please switch this to a code that better represents “minimum requirement not met” (or adjust the logic/message so it represents an exceeded max limit).

Suggested change
core.setFailed(`E002: qmd search "${collectionName}" returned ${fileCount} results, minimum is ${minCount}`);
core.setFailed(`E003: qmd search "${collectionName}" returned ${fileCount} results, minimum is ${minCount}`);

Copilot uses AI. Check for mistakes.
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot use error constants from share helper file

Replace hardcoded E001/E002/E007 string prefixes with named constants
from the shared error_codes.cjs helper file:

- create_issue.cjs: ERR_VALIDATION for close-older-key validation
- create_discussion.cjs: ERR_VALIDATION for close-older-key validation
- push_signed_commits.cjs: ERR_API for OID resolution and GraphQL failures
- qmd_index.cjs: ERR_CONFIG for missing env var / missing SDK,
  ERR_VALIDATION for invalid repo slug and insufficient results count

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/216b3126-6c3b-42d3-9ab5-b2478f209191
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 24, 2026

@copilot use error constants from share helper file

Done in 1ac3ed2. All four files now import and use named constants from error_codes.cjs (ERR_VALIDATION, ERR_CONFIG, ERR_API) instead of hardcoded E00X strings.

@pelikhan pelikhan merged commit 97fbff5 into main Mar 24, 2026
@pelikhan pelikhan deleted the copilot/use-001-fix-standardized-error-codes branch March 24, 2026 11:46
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: Multiple handlers missing standardized error codes

3 participants