Skip to content

Clean up add_workflow_run_comment.cjs: eliminate duplication, add tests#16738

Merged
pelikhan merged 2 commits intomainfrom
copilot/clean-add-workflow-run-comment
Feb 19, 2026
Merged

Clean up add_workflow_run_comment.cjs: eliminate duplication, add tests#16738
pelikhan merged 2 commits intomainfrom
copilot/clean-add-workflow-run-comment

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

Refactors add_workflow_run_comment.cjs to eliminate code duplication and adds comprehensive test coverage.

Changes

Eliminated duplication:

  • Extracted getDiscussionNodeId() helper - GraphQL query was duplicated in discussion and discussion_comment cases
  • Extracted setCommentOutputs() helper - output setting logic was duplicated 3 times across event handlers
  • Replaced 7-case switch statement with EVENT_TYPE_DESCRIPTIONS lookup object + optional chaining

Code quality:

  • Added block-scoped braces to switch cases (fixes ESLint no-case-declarations)
  • Exported addCommentWithWorkflowLink to enable testing

Test coverage:

  • 18 test cases covering all event types (issues, pull_request, discussion, etc.)
  • Tests for error conditions (missing fields, unsupported events, API errors)
  • Tests for feature flags (workflow-id marker, tracker-id, lock notice, reaction type)

Example

Before:

// Duplicate GraphQL queries in discussion and discussion_comment cases
const { repository } = await github.graphql(`query($owner: String!, $repo: String!, $num: Int!) { ... }`, ...);
const discussionId = repository.discussion.id;

After:

// Reusable helper
async function getDiscussionNodeId(discussionNumber) {
  const { repository } = await github.graphql(`query($owner: String!, $repo: String!, $num: Int!) { ... }`, ...);
  return repository.discussion.id;
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh run download 22166965257 -n agent-artifacts -D /tmp/agent-artifacts (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw --check 64/bin/go git conf�� --get remote.origin.url (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha -json GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha blog-auditor.md GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/link GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linux_amd64/link -uns�� 3036063/b404/sliceutil.test /tmp/go-build3223036063/b288/vet.cfg 3036063/b404/importcfg.link GOSUMDB GOWORK 64/bin/go -JPGyIl2vB7_F/G9sEDD2pLhLMDAgEAiXu/X6R5OoPF4X40d7UERB47/kI2eOA--JPGyIl2vB7_F (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha brave.md k/gh-aw/gh-aw/pkg/cli/fileutil/fmain /opt/hostedtoolcache/go/1.25.0/x-lang=go1.25 GOINSECURE GOMOD GOMODCACHE /opt/hostedtoolcache/go/1.25.0/x-dwarf=false -o runs/20260219-040212-30077/test-go1.25.0 -trimpath 3036063/b324/vet.cfg l main -lang=go1.25 /opt/hostedtoolcache/go/1.25.0/x/tmp/go-build3223036063/b421/_testmain.go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha /tmp/TestHashConsistency_GoAndJavaScript1091784387/001/test-complex-frontmatter-@{u} resolved$ /usr/bin/git -json GO111MODULE 64/bin/go git init�� GOMODCACHE go /usr/bin/git -json GO111MODULE x_amd64/vet git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha -json GO111MODULE 64/pkg/tool/linu-nolocalimports GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linu/tmp/go-build3223036063/b412/_testmain.go env -json GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuREDACTED (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha ithub/workflows/archie.md g/timeutil/format_test.go ipts.test -errorsas -ifaceassert -nilfunc ipts.test 2230�� xterm-color -tests /usr/bin/git ECai/9kS0RR28kB5git GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha /tmp/gh-aw-test-runs/20260219-040212-30077/test-1840838544 rev-parse /usr/bin/git @{u} GO111MODULE x_amd64/vet git rev-�� --show-toplevel x_amd64/vet /usr/bin/git -json GO111MODULE x_amd64/vet git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha KJnW/z2r0LREfQX7GOSUMDB GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE 9152170/b401/imp/tmp/go-build3223036063/b114/vet.cfg /hom�� che/go-build/b1/b136a0101c461533GOINSECURE **/*.cjs 64/bin/go **/*.json --ignore-path run-script/lib/n-bool /opt/hostedtoolc-buildtags (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha "prettier" --check '**/*.cjs' '*GOINSECURE GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go /opt/hostedtoolc/tmp/go-build3223036063/b257/vet.cfg -o /tmp/go-build3199152170/b345/_pkGOINSECURE -trimpath 64/bin/go -p main -lang=go1.25 go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha pkg/mod/github.c-errorsas pkg/mod/github.c-ifaceassert 64/bin/go GOSUMDB GOWORK 64/bin/go /opt/hostedtoolc-buildtags -o /tmp/go-build319-errorsas -trimpath 64/bin/go -p testing/internalrev-parse -lang=go1.25 go (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha vaScript1091784387/001/test-simple-frontmatter.md GO111MODULE Name,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle GOINSECURE GOMOD GOMODCACHE /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -ato�� -bool -buildtags 3036063/b338/vet.cfg -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha bot-detection.md GO111MODULE 3036063/b176/vet.cfg GOINSECURE GOMOD GOMODCACHE /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linu/tmp/go-build3223036063/b108/vet.cfg -ato�� -bool -buildtags 3036063/b334/vet.cfg -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuorigin (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linu-importcfg env -json .cfg 64/pkg/tool/linu-buildmode=exe GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linu-extld=gcc (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env -json .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuremote.origin.url (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env g_.a GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuremote.origin.url (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env -json .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path BbC9/PYNcR6J8iK6GOSUMDB GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE 9152170/b395/imp-buildtags /hom�� che/go-build/dd/-errorsas **/*.cjs 64/bin/go **/*.json --ignore-path ../../../.pretti-bool /opt/hostedtoolc-buildtags (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100 GOWORK 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 GOMOD GOMODCACHE x_amd64/link env -json GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 2l/hKXTtrccq1d6W0qIfHov/c9W7SApZ--json (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha -json GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env 3403055332/.github/workflows .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE FyPOPt7/hAqieucyA4npJ9bo6g4b (http block)
  • https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha -json GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env -json .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env -json .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go GOINSECURE GOMOD GOMODCACHE iptables -w -t security 64/bin/go OUTPUT -d run-script/lib/n-bool go (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go GOINSECURE GOMOD GOMODCACHE iptables -w -t security 64/bin/go OUTPUT -d 168.63.129.16 go (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build3223036063/b368/cli.test /tmp/go-build3223036063/b368/cli.test -test.testlogfile=/tmp/go-build3223036063/b368/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true GOINSECURE GOMOD GOMODCACHE 9152170/b361/imp/tmp/go-build3223036063/b095/vet.cfg -c pkg/mod/github.com/pmezard/go-diGOINSECURE GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go /opt/hostedtoolc/tmp/go-build3223036063/b258/vet.cfg (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name vMPf/0LMLcOs4Pm5GOSUMDB GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE 9152170/b387/imp/tmp/go-build3223036063/b159/vet.cfg /hom�� 9152170/b387/embedcfg **/*.cjs 64/bin/go **/*.json --ignore-path ../../../.pretti-bool /opt/hostedtoolc-buildtags (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[jsweep] Clean add_workflow_run_comment.cjs</issue_title>
<issue_description>## Summary

Cleaned actions/setup/js/add_workflow_run_comment.cjs and added comprehensive tests.

Context type: github-script context

Changes Made

add_workflow_run_comment.cjs

  1. Block-scoped switch cases – Added {} braces to each case block in main() to fix lexical declaration issues with const inside switch cases (ESLint no-case-declarations rule).

  2. Lookup object for event descriptions – Replaced the 7-case switch statement for eventTypeDescription with a concise EVENT_TYPE_DESCRIPTIONS lookup object + optional chaining (??), reducing ~18 lines to 9 lines.

  3. Extracted getDiscussionNodeId() helper – The identical GraphQL query to fetch a discussion node ID was duplicated for both discussion and discussion_comment event cases. Extracted to a shared helper function.

  4. Extracted setCommentOutputs() helper – The core.setOutput calls for comment-id, comment-url, and comment-repo were duplicated 3 times. Extracted to a shared helper function.

  5. Exported addCommentWithWorkflowLink – Added to module.exports to enable testing.

add_workflow_run_comment.test.cjs (new file)

Created comprehensive test coverage with 18 test cases:

main() tests (12 cases):

  • Issues event: creates comment, fails when issue number missing
  • issue_comment event: creates comment on the issue
  • pull_request event: creates comment, fails when PR number missing
  • pull_request_review_comment event: creates comment
  • discussion event: creates GraphQL comment, fails when number missing
  • discussion_comment event: creates threaded comment with replyToId, fails when fields missing
  • Unsupported event types: calls setFailed
  • API errors: warns but does not fail the job

addCommentWithWorkflowLink() tests (6 cases):

  • Includes workflow-id marker when GITHUB_WORKFLOW is set
  • Includes tracker-id marker when GH_AW_TRACKER_ID is set
  • Always includes reaction comment type marker
  • Adds lock notice for issues events when GH_AW_LOCK_FOR_AGENT=true
  • Does not add lock notice for pull_request events
  • Sets all required outputs (comment-id, comment-url, comment-repo)

Validation ✅

  • Formatting: npm run format:cjs
  • Linting: npm run lint:cjs
  • Type checking: npm run typecheck
  • Tests: npm run test:js – 18/18 passed ✓

AI generated by jsweep - JavaScript Unbloater

  • expires on Feb 21, 2026, 3:22 AM UTC

[!NOTE]
This was originally intended as a pull request, but the git push operation failed.

Workflow Run: View run details and download patch artifact

The patch file is available in the agent-artifacts artifact in the workflow run linked above.

To apply the patch locally:

# Download the artifact from the workflow run https://github.com/github/gh-aw/actions/runs/22166965257
# (Use GitHub MCP tools if gh CLI is not available)
gh run download 22166965257 -n agent-artifacts

# The patch file will be at agent-artifacts/tmp/gh-aw/aw.patch after download
# Apply the patch
git am agent-artifacts/tmp/gh-aw/aw.patch
Show patch preview (500 of 627 lines)
From d40b021908ad7814d28757c1173e99572bcd397c Mon Sep 17 00:00:00 2001
From: GitHub Copilot <copilot@github.com>
Date: Thu, 19 Feb 2026 03:16:22 +0000
Subject: [PATCH] jsweep: clean add_workflow_run_comment.cjs and add tests

- Add block scoping to switch cases (fixes no-case-declarations lint issue)
- Replace event type description switch with lookup object (EVENT_TYPE_DESCRIPTIONS)
- Extract getDiscussionNodeId() helper to DRY up duplicate GraphQL queries
- Extract setCommentOutputs() helper to remove repeated output-setting code
- Export addCommentWithWorkflowLink for testing
- Add 18 comprehensive tests covering all event types and edge cases

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 actions/setup/js/add_workflow_run_comment.cjs | 204 ++++++-------
 .../js/add_workflow_run_comment.test.cjs      | 272 ++++++++++++++++++
 2 files changed, 365 insertions(+), 111 deletions(-)
 create mode 100644 actions/setup/js/add_workflow_run_comment.test.cjs

diff --git a/actions/setup/js/add_workflow_run_comment.cjs b/actions/setup/js/add_workflow_run_comment.cjs
index e309e0b..130a975 100644
--- a/actions/setup/js/add_workflow_run_comment.cjs
+++ b/actions/setup/js/add_workflow_run_comment.cjs
@@ -6,6 +6,54 @@ const { getErrorMessage } = require("./error_helpers.cjs");
 const { generateWorkflowIdMarker } = require("...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes github/gh-aw#16736

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Clean up add_workflow_run_comment.cjs and enhance tests Clean up add_workflow_run_comment.cjs: eliminate duplication, add tests Feb 19, 2026
@pelikhan pelikhan marked this pull request as ready for review February 19, 2026 04:06
Copilot AI review requested due to automatic review settings February 19, 2026 04:06
Copy link
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

Refactors add_workflow_run_comment.cjs to reduce duplication and adds Vitest coverage for workflow-run comment creation across supported GitHub event types.

Changes:

  • Extracted helpers (getDiscussionNodeId, setCommentOutputs) and simplified event type description selection via EVENT_TYPE_DESCRIPTIONS.
  • Added block-scoped switch case bodies to avoid no-case-declarations issues.
  • Added a new add_workflow_run_comment.test.cjs with coverage for main flows, error paths, and feature flags; exported addCommentWithWorkflowLink to enable direct testing.

Reviewed changes

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

File Description
actions/setup/js/add_workflow_run_comment.cjs Refactors event handling and comment creation (REST + GraphQL) with shared helpers and exported function for testing.
actions/setup/js/add_workflow_run_comment.test.cjs Adds Vitest coverage for supported event types, failures, and comment body markers/outputs.
Comments suppressed due to low confidence (2)

actions/setup/js/add_workflow_run_comment.cjs:236

  • commentNodeId can be undefined for discussion_comment payloads, but it’s passed directly as replyToId to the GraphQL mutation. Add an explicit check and produce a clear failure (and add a test for the missing-node_id case) so this doesn’t fail later with a GraphQL validation error.

This issue also appears on line 130 of the same file.

    // Get the comment node ID to use as the parent for threading
    const commentNodeId = context.payload?.comment?.node_id;

actions/setup/js/add_workflow_run_comment.cjs:134

  • For discussion_comment events, addCommentWithWorkflowLink relies on context.payload.comment.node_id as the replyToId, but this switch case only validates comment.id. If node_id is missing, the GraphQL mutation will be invoked with an invalid replyToId and will fail later. Please validate context.payload.comment.node_id here (or pass it through the endpoint) and fail early with a specific message when it’s missing.
        const discussionCommentNumber = context.payload?.discussion?.number;
        const discussionCommentId = context.payload?.comment?.id;
        if (!discussionCommentNumber || !discussionCommentId) {
          core.setFailed("Discussion or comment information not found in event payload");
          return;

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

}
}`,
{ owner: context.repo.owner, repo: context.repo.repo, num: discussionNumber }
);
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

getDiscussionNodeId assumes repository.discussion is always present. If discussions are disabled or the discussion number is invalid, this will throw a generic TypeError when accessing .id, making failures hard to diagnose. Please guard against a missing discussion and throw/return a clearer error (e.g., include owner/repo and discussion number) before accessing .id.

Suggested change
);
);
if (!repository || !repository.discussion) {
throw new Error(
`Could not find discussion #${discussionNumber} in ${context.repo.owner}/${context.repo.repo}. ` +
`Discussions may be disabled for this repository or the discussion number may be invalid.`
);
}

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit a6efcf8 into main Feb 19, 2026
155 checks passed
@pelikhan pelikhan deleted the copilot/clean-add-workflow-run-comment branch February 19, 2026 04:12
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.

2 participants

Comments