Skip to content

fix(create-discussion): prevent double-posting when GraphQL mutation partially succeeds#22601

Merged
pelikhan merged 6 commits intomainfrom
copilot/fix-agentic-workflows-double-posting
Mar 24, 2026
Merged

fix(create-discussion): prevent double-posting when GraphQL mutation partially succeeds#22601
pelikhan merged 6 commits intomainfrom
copilot/fix-agentic-workflows-double-posting

Conversation

Copy link
Contributor

Copilot AI commented Mar 24, 2026

create-discussion workflows would simultaneously create a Discussion and a fallback issue bearing the message "This was intended to be a discussion, but discussions could not be created due to permissions issues."

Root cause

@octokit/graphql throws a GraphqlResponseError when the API returns both data and errors in the same response body. When createDiscussion partially succeeds this way — the discussion is persisted, but the response carries an error (e.g. a post-creation permission check) — the thrown error's message matches isPermissionsError(), causing handleFallbackToIssue() to fire even though the discussion already exists.

Fix (create_discussion.cjs)

Two guards in the outer catch block prevent the fallback from firing when a discussion was already created:

  • createdDiscussion flag — set immediately after the mutation result is validated; catches any post-creation error that unexpectedly escapes its inner try-catch
  • error.data?.createDiscussion?.discussion check — reads partial success data from the GraphqlResponseError itself; covers the confirmed root cause path
/** @type {{id: string, number: number, title: string, url: string} | null | undefined} */
const partialDiscussion = /** @type {any} */ (error)?.data?.createDiscussion?.discussion;
const resolvedDiscussion = createdDiscussion || partialDiscussion;
if (resolvedDiscussion) {
  core.warning(`Discussion …#${resolvedDiscussion.number} was created but a post-creation operation failed: ${errorMessage}`);
  return { success: true, repo: qualifiedItemRepo, number: resolvedDiscussion.number, url: resolvedDiscussion.url };
}

When either guard fires, the handler returns success with the discussion's details and logs a warning — no fallback issue is created.

Tests (create_discussion_fallback.test.cjs)

  • should NOT create a fallback issue when the discussion was already created — attaches GraphqlResponseError-style partial data to the thrown error and asserts no issue is created
  • should still fall back to an issue when discussion creation itself fails — regression guard ensuring clean failures (no partial data) still trigger the fallback correctly

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 /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 GO111MODULE 64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/docker 7497120/b191/_pkgit GO111MODULE .cfg docker (http block)
    • Triggering command: /usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name /usr/bin/git SameOutput112211git /tmp/go-build334rev-parse Name,createdAt,s--show-toplevel git otOr�� --show-toplevel ui9DXErNUqbp0/-W62TvCQswySHDXD2KP5/IKo0RnU6mvci67yPKw6j/HSDucSmurev-parse /usr/bin/git licyMinIntegritygit /tmp/go-build334rev-parse t git (http block)
    • Triggering command: /usr/bin/gh gh repo view owner/repo 0/x6�� --show-toplevel /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linuorigin /usr/bin/git itattributes-tesgit -buildtags 3318903/b312/vet--show-toplevel git rev-�� --show-toplevel /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet /usr/bin/git -bool l 0/x64/bin/node git (http block)
  • https://api.github.com/orgs/test-owner/actions/secrets
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha --show-toplevel x_amd64/vet 3318903/b456/vet.cfg -json GO111MODULE x_amd64/vet git rev-�� --show-toplevel x_amd64/vet /usr/bin/git g_.a @v1.1.3/base64/brev-parse x_amd64/vet /usr/bin/git (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 3318903/b436/_pkg_.a -buildtags epo.git -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/compile -o ithub-script/git/ref/tags/v8 -trimpath /usr/bin/git -p main -lang=go1.25 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 ortcfg GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env 7497120/b179/_pkg_.a GO111MODULE .cfg GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel x_amd64/vet /usr/bin/git g_.a GO111MODULE x_amd64/vet git rev-�� --show-toplevel dx8vjli/alK5YuEvsiWHJxF12LLI /usr/bin/git ty-test.md .cfg 64/pkg/tool/linu--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet /usr/bin/git st-2878541572/.ggit 3318903/b180/vetrev-parse .cfg git rev-�� --show-toplevel ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet 86_64/node /tmp/go-build152git -trimpath ache/go/1.25.0/x--show-toplevel git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha -test.paniconexit0 -test.v=true /usr/bin/git -test.timeout=10git -test.run=^Test -test.short=true--show-toplevel git -C nt/action/git/ref/tags/v999.999.999 rev-parse /opt/hostedtoolcache/node/24.14.0/x64/bin/node @{u} GO111MODULE nch,headSha,disp--show-toplevel node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha /tmp/TestHashConsistency_GoAndJavaScript3248392866/001/test-fronv1.0.0 x_amd64/compile /usr/bin/git d GO111MODULE x_amd64/vet git rev-�� --show-toplevel x_amd64/vet /usr/bin/git -json @v1.1.3/internalrev-parse x_amd64/vet git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha --show-toplevel ache/go/1.25.0/x64/pkg/tool/linu/home/REDACTED/work/gh-aw/gh-aw/pkg/stringutil/identifiers.go /usr/bin/git se 3318903/b230/vetrev-parse .cfg git rev-�� --show-toplevel ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet /usr/bin/git 2912-30964/test-git -trimpath ache/go/1.25.0/x--show-toplevel 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 e_wasm.s GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json gset/set.go x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha -c=4 -nolocalimports -importcfg /tmp/go-build3343318903/b418/importcfg -pack /home/REDACTED/work/gh-aw/gh-aw/pkg/logger/doc.go /home/REDACTED/work/gh-aw/gh-aw/pkg/logger/logger.go env -json age/compact/comp-ifaceassert x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (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 /tmp/go-build3343318903/b441/testutil.test -importcfg /usr/bin/git -s -w -buildmode=exe git rev-�� --git-dir -extld=gcc /usr/bin/git -json GO111MODULE x_amd64/vet git (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 /tmp/go-build3343318903/b441/_pkg_.a -trimpath /usr/bin/git -p main -lang=go1.25 git comm�� -m Add workflow /usr/bin/git go1.25.0 -c=4 -nolocalimports git (http block)
  • https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq .object.sha -unreachable=false /tmp/go-build3343318903/b036/vet.cfg 3318903/b351/vet.cfg -goversion go1.25.0 -c=4 /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -uns�� ithub-script/git/ref/tags/v8 /tmp/go-build3343318903/b218/vet.cfg /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet --check scripts/**/*.js 64/bin/go /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha 2912-30964/test-2872516719 /tmp/go-build3343318903/b092/vet.cfg 3318903/b361/vet.cfg go1.25.0 -c=4 -nolocalimports /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -uns�� -unreachable=false /tmp/go-build3343318903/b239/vet.cfg 3318903/b436/stringutil.test -mod=readonly tions.go 64/bin/go 3318903/b436/stringutil.test (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha runs/20260324-052912-30964/test-1629784668/.github/workflows /tmp/go-build3343318903/b083/vet.cfg 3318903/b356/vet.cfg l -c=4 -nolocalimports /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -uns�� k/gh-aw/gh-aw/.github/workflows /tmp/go-build3343318903/b236/vet.cfg /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -json GOCACHE 64/bin/go /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 fMTeOyAsi 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linutest@example.com estl�� ortcfg .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE 96f6dc2b017512b7config GOMODCACHE 64/pkg/tool/linuremote.origin.url (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 jfQ9JkmbI x_amd64/compile GOINSECURE go-sdk/internal/rev-parse GOMODCACHE x_amd64/compile env g_.a GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuTest User (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 f3WNIxf6L 64/pkg/tool/linux_amd64/compile GOINSECURE v3 GOMODCACHE 64/pkg/tool/linux_amd64/compile estl�� g_.a GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE hEwAuVNuvCtXv/3Wconfig GOMODCACHE 64/pkg/tool/linutest@example.com (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 TAWkEgFot x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env YFesNwKSb .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE %H %ct %D GOMODCACHE 64/pkg/tool/linux_amd64/vet (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 ipBU_UDMP x_amd64/compile GOINSECURE gset GOMODCACHE x_amd64/compile env RHWPMZAE3 .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/4/artifacts
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 PZlisUvcs 64/pkg/tool/linux_amd64/vet GOINSECURE age GOMODCACHE 64/pkg/tool/linux_amd64/vet env _jk-OnU_6 .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/5/artifacts
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 WfTa2tL3Z 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env ortcfg .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 sm-opt -Oz (size optimization)..."; \ BEFORE=$(wc -c < gh-aw.wasm); \ wasm-opt/tmp/go-build3343318903/b414/importcfg GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (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 GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (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 64/pkg/tool/linuorigin ns-l�� ortcfg .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/contents/.github/workflows/shared/reporting.md
    • Triggering command: /tmp/go-build3343318903/b400/cli.test /tmp/go-build3343318903/b400/cli.test -test.testlogfile=/tmp/go-build3343318903/b400/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (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 KDUEEbjqb .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet ortc�� 7497120/b101/_pkg_.a .cfg x_amd64/compile GOINSECURE b/gh-aw/pkg/tty GOMODCACHE x_amd64/compile (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v2.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json 8601/parse.go x_amd64/compile GOINSECURE GOMOD GOMODCACHE FMXAZENQ7Ra6 env -json GO111MODULE x_amd64/vet GOINSECURE mcpgodebug GOMODCACHE x_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v3.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (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 ty-test.md .cfg At,event,headBranch,headSha,displayTitle GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet ortc�� ithout_min-integrity1193647606/001 g/console/accessibility.go 64/pkg/tool/linux_amd64/vet GOINSECURE l 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 1420279602/.github/workflows .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE 7497120/b015/ 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 x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json /context.go x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json l/errors/error.go x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh workflow list --repo owner/repo --json name,path,state /usr/bin/git 3318903/b415/filgit /tmp/go-build334rev-parse 3318903/b415/imp--show-toplevel git rev-�� --show-toplevel IC8zTipfMwGSL/WqPmaxUgULkS6lBtndrk/cnjHJRsC75-1TI1_m0Vn/uTsMpJMIC8zTipfMwGSL /usr/bin/git -instructions-tegit -buildtags 3318903/b415/_pk--show-toplevel git (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build3343318903/b400/cli.test /tmp/go-build3343318903/b400/cli.test -test.testlogfile=/tmp/go-build3343318903/b400/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (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 -json GO111MODULE x_amd64/asm GOINSECURE GOMOD GOMODCACHE x_amd64/asm env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
  • https://api.github.com/repos/test/repo
    • Triggering command: /usr/bin/gh gh api /repos/test/repo --jq .default_branch --show-toplevel /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet /usr/bin/git -unreachable=falgit resolved$ 3318903/b349/vet--show-toplevel git rev-�� --show-toplevel /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet /usr/bin/git runs/20260324-05git /tmp/go-build334rev-parse /opt/hostedtoolc--show-toplevel git (http block)

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI linked an issue Mar 24, 2026 that may be closed by this pull request
When the GitHub GraphQL API returns both `data` and `errors` in a
`createDiscussion` mutation response (a GraphqlResponseError from
@octokit/graphql), the discussion is already persisted in GitHub's
database but the code previously fell through to the fallback-to-issue
path — producing both a discussion and a fallback issue with the same
title.

Two guards are added in the outer catch block:
1. A `createdDiscussion` flag set after the mutation is confirmed valid,
   protecting against any post-creation operation error that unexpectedly
   escapes its inner try-catch.
2. A check of `error.data?.createDiscussion?.discussion` for partial
   success data attached to a GraphqlResponseError, covering the confirmed
   root cause.

In either case the handler returns success with the discussion details
and a warning, without creating a fallback issue.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/26ef7c45-6bba-4d0e-826e-7af38ed22870
Copilot AI changed the title [WIP] Fix double posting issue in Agentic Workflows fix(create-discussion): prevent double-posting when GraphQL mutation partially succeeds Mar 24, 2026
Copilot AI requested a review from pelikhan March 24, 2026 05:36
@pelikhan pelikhan marked this pull request as ready for review March 24, 2026 05:40
Copilot AI review requested due to automatic review settings March 24, 2026 05:40
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

Fixes create-discussion fallback behavior to prevent creating a fallback issue when the Discussion was actually created but the GraphQL call still threw due to partial data + errors responses.

Changes:

  • Track successful discussion creation and short-circuit the outer error handler to avoid fallback issue creation.
  • Detect partial-success discussion data on GraphqlResponseError (error.data...) and treat the run as successful with a warning.
  • Add regression tests covering partial-success errors vs. true discussion-creation failures.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
actions/setup/js/create_discussion.cjs Adds guards in the outer catch to treat partial-success discussion creation as success and avoid fallback issue double-posting.
actions/setup/js/create_discussion_fallback.test.cjs Adds tests to ensure fallback issue creation does not happen on partial-success GraphQL errors, and still happens on true creation failures.

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

@pelikhan
Copy link
Contributor

@copilot fix CI / js (pull_request)Failing after 26s
CI / js-integration-live-api (pull_request)
CI / js-integration-live-api (pull_request)Failing after 23s
CI / js-qmd-index (pull_request)
CI / js-qmd-index (pull_request)Failing after 21s

The @type {any} JSDoc cast requires parentheses: `/** @type {any} */ (expr)`.
Without them TypeScript does not treat it as a cast and reports a type error.
Prettier was stripping the parens — add `// prettier-ignore` (same pattern
used in assign_agent_helpers.cjs) to preserve them so `tsc --noEmit` passes.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/6b0f8428-4bb0-4473-9541-b9cf98602b4d
Copy link
Contributor Author

Copilot AI commented Mar 24, 2026

@copilot fix CI / js (pull_request)Failing after 26s
[CI / js-integration-live-api (pull_request)](https://github....

Fixed in 9e9e7bf. The CI failure was a TypeScript error: Property 'data' does not exist on type '{}'. Prettier was stripping the parentheses from /** @type {any} */ (error), breaking the JSDoc cast. Added // prettier-ignore (same pattern used in assign_agent_helpers.cjs) to preserve the parens so tsc --noEmit passes.

@pelikhan
Copy link
Contributor

@copilot fix more CI / build-wasm (pull_request)Failing after 58s
CI / test (pull_request)
CI / test (pull_request)Failing after 1m

@pelikhan pelikhan merged commit 8aa5be1 into main Mar 24, 2026
46 of 48 checks passed
@pelikhan pelikhan deleted the copilot/fix-agentic-workflows-double-posting branch March 24, 2026 06:09
Copilot stopped work on behalf of pelikhan due to an error March 24, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agentic Workflows Double Posting

3 participants