Skip to content

refactor: extract parseMCPScriptToolConfig helper to eliminate duplication in mcp_scripts_parser.go#28897

Merged
pelikhan merged 5 commits intomainfrom
copilot/refactor-extract-parsemcpscripttoolconfig-helper
Apr 28, 2026
Merged

refactor: extract parseMCPScriptToolConfig helper to eliminate duplication in mcp_scripts_parser.go#28897
pelikhan merged 5 commits intomainfrom
copilot/refactor-extract-parsemcpscripttoolconfig-helper

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

parseMCPScriptsMap and the inner loop of mergeMCPScripts contained identical ~100-line blocks for parsing a single MCP script tool config from map[string]any. Any new MCPScriptToolConfig field required two separate edits — as evidenced by the uint64 overflow fix being patched independently at both sites (alerts #413 and #414).

Changes

  • New helper parseMCPScriptToolConfig(toolName string, toolMap map[string]any) *MCPScriptToolConfig consolidates all single-tool parsing: description, inputs/params, script/run/py/go, env, and timeout (including the safe uint64 overflow conversion, now in one place referencing both original alerts).
  • parseMCPScriptsMap — duplicated block replaced with config.Tools[toolName] = parseMCPScriptToolConfig(toolName, toolMap).
  • mergeMCPScripts — duplicated block replaced with main.Tools[toolName] = parseMCPScriptToolConfig(toolName, toolMap).

Net: −97 lines, one canonical parsing path, one timeout switch in production code.

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 repo view --json owner,name --jq .owner.login + "/" + .name ache/go/1.25.8/x64/pkg/tool/linu-lang=go1.25 GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linu-dwarf=false (http block)
    • Triggering command: /usr/bin/gh gh repo view owner/repo 8898�� 2528806108/.github/workflows 9848889/b022/vet.cfg ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh repo view owner/repo 8898�� 2528806108/.github/workflows 9848889/b026/vet.cfg ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linu-buildtags (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 8601/parse.go 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/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, .object.type] | @tsv --show-toplevel 64/pkg/tool/linu/tmp/go-build2889848889/b114/vet.cfg /usr/bin/git ithub/workflows til_test.go 64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linux_amd64/compile /usr/bin/git g_.a 9848889/b146/vet/opt/hostedtoolcache/node/24.14.1/x64/bin/npm .cfg 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, .object.type] | @tsv 2311-33545/test-1797178761 9848889/b466/_testmain.go /usr/bin/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, .object.type] | @tsv 2311-33545/test---workflow -trimpath g_.a -p golang.org/x/sys-1 -lang=go1.25 ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -uns�� 2311-33545/test-1677168725 /tmp/go-build2889848889/b011/vet.cfg 9848889/b279/vet.cfg go1.25.8 -c=4 -nolocalimports /opt/hostedtoolcache/go/1.25.8/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, .object.type] | @tsv --show-toplevel x_amd64/vet /usr/bin/git se 9848889/b239/vet\n ache/go/1.25.8/x: git rev-�� --show-toplevel ache/go/1.25.8/xremote /usr/bin/git /tmp/go-build412git -trimpath /opt/hostedtoolc--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git sistency_KeyOrdegit 4tjTvzWk1dz_ /usr/bin/gh git rev-�� --show-toplevel gh /usr/bin/git /repos/actions/ggit s/5/artifacts /usr/bin/infocmp--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, .object.type] | @tsv P9ch/sR1tjYVSqOEP82kiP9ch -buildtags /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linuother 9848�� g/cli 9848889/b420/_testmain.go ache/go/1.25.8/x64/pkg/tool/linux_amd64/link -errorsas -ifaceassert -nilfunc ache/go/1.25.8/x64/pkg/tool/linu-buildtags (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv runs/20260428-102311-33545/test-1677168725 -buildtags ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -errorsas -ifaceassert -nilfunc ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet init�� -stringintconv -tests /usr/bin/git -json GO111MODULE x_amd64/asm git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv -m (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, .object.type] | @tsv --show-toplevel /opt/hostedtoolcremote /usr/bin/git 2311-33545/test-git /tmp/go-build288rev-parse e/git-upload-pacHEAD git rev-�� --show-toplevel /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linu-tests /usr/bin/git -unreachable=falgit /tmp/go-build288rev-parse /opt/hostedtoolc--show-toplevel git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v9
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv -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)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv -json GO111MODULE x_amd64/asm GOINSECURE GOMOD GOMODCACHE x_amd64/asm env -json /context.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/v9 --jq [.object.sha, .object.type] | @tsv -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json .go 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, .object.type] | @tsv --git-dir xf9qL--/YcBrNqCW-dwarf=false 9848889/b471/vet.cfg ty-test.md .cfg 64/pkg/tool/linu--show-toplevel /usr/bin/git remo�� -v 64/pkg/tool/linuremote.origin.url /tmp/go-build2889848889/b469/workflow.test y_with_repos_arrgit d2UJ/DbmGN00V4XBrev-parse 64/pkg/tool/linu--show-toplevel /tmp/go-build2889848889/b469/workflow.test (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, .object.type] | @tsv GOMODCACHE sgM1d_TR1DWb clusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle -json 90 x_amd64/vet node /tmp�� /tmp/TestHashConsistency_GoAndJavaScript1872459530/001/test-frontmatter-with-env-template-expresgit x_amd64/vet /usr/bin/git -json GO111MODULE x_amd64/vet git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv /home/REDACTED/work/gh-aw/gh-aw/.github/workflows/archie.md 64/pkg/tool/linux_amd64/vet 9848889/b468/vet.cfg mLsRemoteWithReagit mLsRemoteWithRearev-parse 64/pkg/tool/linu--show-toplevel infocmp -1 xterm-color 64/pkg/tool/linumyorg /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/link y_with_repos=pubgit V4ci/NWzImF-917Hrev-parse 64/pkg/tool/linu--show-toplevel /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/link (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv 3 /tmp/go-build2889848889/b083/vet.cfg 9848889/b424/_pkg_.a -json GO111MODULE 64/bin/go /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -ato�� licyMinIntegrityOnlymin-integrity_with_repos_array_c1047187760/001 -buildtags ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile l -ifaceassert -nilfunc ache/go/1.25.8/x64/pkg/tool/linu-test.v=true (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv runs/20260428-102311-33545/test-1677168725 -buildtags x_amd64/compile l -ifaceassert -nilfunc x_amd64/compile t-41�� bility_SameInputSameOutput1915623955/001/stability-test.md Test User /usr/bin/git -json GO111MODULE x_amd64/compile git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv origin l /usr/bin/git -json color.go x_amd64/compile git -C /tmp/TestGuardPolicyTrustedUsersRequiresMinIntegrity1291689616/001 remote /usr/bin/git -json GO111MODULE x_amd64/vet 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, .object.type] | @tsv /tmp/gh-aw-test-runs/20260428-102311-33545/test-449180148/.githu.github/workflows/test.md config ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet remote.origin.urgit 2/compile.go x_amd64/compile ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b
    • Triggering command: /usr/bin/gh gh api /repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b --jq [.object.sha, .object.type] | @tsv user.email ings.cjs n-dir/git set-url 22cdce26..full-mrun modules/@npmcli//tmp/go-handler-test-xCtH48/slow.go forks.js rev-�� HEAD st/suppress-warnings.cjs (http block)
    • Triggering command: /usr/bin/gh gh api /repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b --jq [.object.sha, .object.type] | @tsv . git $name) { hasDiscussionsEnabled } } -M full mode test tnet/tools/git git init�� -q (http block)
    • Triggering command: /usr/bin/gh gh api /repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b --jq [.object.sha, .object.type] | @tsv . st/dist/workers/forks.js ndor/bin/git --bare full mode test 1/x64/bin/git git init�� -q st/suppress-warn--conditions ache/node/24.14.development -b 1d6e5d7d /git st/dist/workers/-f (http block)
  • https://api.github.com/repos/github/gh-aw
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw --jq .default_branch -output.go tions/setup/js/n--output=/tmp/git-patch-utils-nvtLYO/.diffsize.tmp r: $owner, name: $name) { hasDiscussionsEnabled } } tions/node_modulgit git 1/x64/lib/node_m/home/REDACTED/work/gh-aw/gh-aw 1/x64/bin/node ve . tions/setup/js/node_modules/vitest/suppress-warnings.cjs r: $owner, name: $name) { hasDiscussionsEnabled } } -exist mp odules/npm/node_/home/REDACTED/work/gh-aw/gh-aw tions/setup/js/nshow (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw --jq .default_branch -M main ock.yml --require /home/REDACTED/wor-C /usr/sbin/git go run ithub/workflows git repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } feature && echo git ings.cjs 86_64/git /opt/hostedtoolcshow (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v0.1.2
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq [.object.sha, .object.type] | @tsv --show-toplevel 64/pkg/tool/linuremote /usr/bin/git ortcfg GO111MODULE 64/pkg/tool/linu--show-toplevel /usr/bin/git conf�� --get-regexp ^remote\..*\.gh-resolved$ /usr/bin/git 2523471/b197/_pkgit -QbQ/h0mDcb4RKnBrev-parse 64/pkg/tool/linu--show-toplevel git (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, .object.type] | @tsv /tmp/TestGuardPolicyMinIntegrityOnlymin-integrity_with_repos=public_1400395754/001 l /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile remote.origin.urgit GO111MODULE x_amd64/compile /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linu-buildtags -o /tmp/go-build2889848889/b444/_pkg_.a -trimpath /usr/bin/git -p main -lang=go1.25 git (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, .object.type] | @tsv 9848889/b472/_pkg_.a x_amd64/compile 9848889/b472=> -json GO111MODULE x_amd64/compile git -C poJ_/sX9FX53sm1OTZ6jdpoJ_ show om/org2/repo2.git -json GO111MODULE x_amd64/vet git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-04-21 go-sdk/auth GOMODCACHE x_amd64/compile env RUoqI5yik .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE /exithook GOMODCACHE 64/pkg/tool/linutest-branch (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-03-29 GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env tmatter-with-arrays.md .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE 2523471/b047/ GOMODCACHE 64/pkg/tool/linu--auto (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-01-28 GOMOD GOMODCACHE 64/pkg/tool/linuorigin ortc�� ned-imports-enabled-with-body-content.md .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE 2523471/b007/ GOMODCACHE 64/pkg/tool/linuTest User (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name l_test.go 64/pkg/tool/linux_amd64/compile GOINSECURE 2523471/b011/memconfig ache/go/1.25.8/xuser.email 64/pkg/tool/linutest@example.com (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 gLhb/hBEUOkjpLNrZf4ikgLhb ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linu--jq -c 3976559001/custom/workflows Fuh-/RCcUnszHB3ob-AbBFuh- .cfg GOSUMDB GOWORK 64/bin/go ache/go/1.25.8/x64/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 api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name gimq/JO2tKXBdToMtOLMlgimq 64/pkg/tool/linux_amd64/vet GOINSECURE b/gh-aw/pkg/consrev-parse GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE ntio/asm/keyset 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 api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE b/gh-aw/pkg/strirev-parse GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 .cfg ionpins.test GOINSECURE ntio/asm/ascii GOMODCACHE ionpins.test 8898�� 2528806108/.github/workflows 9848889/b026/vet.cfg ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linu-buildtags (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE 2523471/b011/memrev-parse ache/go/1.25.8/x--git-dir 64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 stmain.go ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linu-buildtags (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE fips140/nistec ache/go/1.25.8/x--show-toplevel ES/TLZMQzrPAL-Nujhl_RSU/IAj1BIRQ--jq (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 bYse/Agvt9vB4Z3tFs27lbYse .cfg GOINSECURE fips140/hkdf GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linu-buildtags (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/link GOINSECURE 2523471/b011/rt0rev-parse ache/go/1.25.8/x--show-toplevel 64/pkg/tool/linux_amd64/link (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 O8a-/w8uJjXynBhCHi02xO8a- ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet GOINSECURE fips140/ecdsa GOMODCACHE ache/go/1.25.8/x64/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 api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE 2523471/b011/sysrev-parse ache/go/1.25.8/x--show-toplevel 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 GO111MODULE .cfg GOINSECURE 2523471/b078/js_rev-parse ache/go/1.25.8/x--show-toplevel ache/go/1.25.8/x64/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 -json cii.go 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 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/vet env 3847821954/.github/workflows @v1.19.2/ast/ast.go 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 2523471/b036/asmrun ache/go/1.25.8/xlist 64/pkg/tool/linu--json env sm-opt >/dev/nul--limit G1PQ/JYbkfQ24Wgm100 ache/go/1.25.8/x--created GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/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-build2889848889/b404/cli.test /tmp/go-build2889848889/b404/cli.test -test.testlogfile=/tmp/go-build2889848889/b404/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true 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/github/gh-aw/git/ref/tags/v0.47.4
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq [.object.sha, .object.type] | @tsv --show-toplevel ache/go/1.25.8/x64/pkg/tool/linuremote.myorg.url /usr/bin/git ApprovalLabelsCogit -trimpath x_amd64/vet git rev-�� --show-toplevel x_amd64/vet /usr/bin/git /tmp/go-build288du -trimpath 9848889/b343/vet/tmp/gh-aw/aw-feature-branch.patch git (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, .object.type] | @tsv plorer.md 9848889/b004/vet.cfg .cfg -p internal/goarch -lang=go1.25 ache/go/1.25.8/x64/pkg/tool/linuTest User 2523�� JyM6o-Ioz pkg/mod/github.com/modelcontextprotocol/go-sdk@v1.5.0/jsonrpc/js-ifaceassert ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -p net/netip -lang=go1.25 ache/go/1.25.8/x12345 (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, .object.type] | @tsv -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env 059673/001 059673/002/work 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, .object.type] | @tsv -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet 0596�� g_.a 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, .object.type] | @tsv json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet 0596�� -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, .object.type] | @tsv successfully" GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env g_.a GO111MODULE x_amd64/vet GOINSECURE GOMOD 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, .object.type] | @tsv " GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env g_.a 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, .object.type] | @tsv 30/001/test-complex-frontmatter-with-tools.md 9848889/b034/vet.cfg k -I /tmp/go-build412rev-parse -I ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet sRem�� se 9848889/b121/vet.cfg ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -p internal/filepatarchive -lang=go1.25 ache/go/1.25.8/xv1.0.0 (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 ache/go/1.25.8/x64/pkg/tool/linuremote.origin.url (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 GO111MODULE x_amd64/vet GOINSECURE GOMOD sm_wasm.s x_amd64/vet (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 GO111MODULE x_amd64/vet GOINSECURE GOMOD emclr_wasm.s x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh workflow list --repo owner/repo --json name,path,state ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/xremote.origin.url estl�� /tmp/go-build4122523471/b105/_pkg_.a k/gh-aw/gh-aw/pkg/stringutil/ansi.go .cfg -p log/internal -lang=go1.25 ache/go/1.25.8/x64/pkg/tool/linurev-parse (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 x86.go 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/test/repo
    • Triggering command: /usr/bin/gh gh api /repos/test/repo --jq .default_branch 3976559001/custom/workflows 9848889/b091/vet.cfg .cfg GOSUMDB GOWORK 64/bin/go ache/go/1.25.8/x64/pkg/tool/linu-tests -p 2523471/b200/importcfg -trimpath x_amd64/compile -I /tmp/go-build412run -I x_amd64/compile (http block)
  • invalid.example.invalid
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin https://invalid.example.invalid/nonexistent-repo.git e/git init�� ndor/bin/git git ode_modules/.bin/git =receive test@example.com--git-dir=/tmp/bare-incremental-RHjwaK /git (dns block)

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

…on in mcp_scripts_parser.go

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/0ca01765-b782-4d25-919b-ec2a93f4fcaf

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor to extract parseMCPScriptToolConfig helper for cleaner code refactor: extract parseMCPScriptToolConfig helper to eliminate duplication in mcp_scripts_parser.go Apr 28, 2026
Copilot AI requested a review from pelikhan April 28, 2026 10:29
@pelikhan pelikhan marked this pull request as ready for review April 28, 2026 10:34
Copilot AI review requested due to automatic review settings April 28, 2026 10:34
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

Refactors MCP scripts parsing by extracting a shared helper to eliminate duplicated parsing logic and centralize timeout handling.

Changes:

  • Added parseMCPScriptToolConfig to parse a single MCP script tool from map[string]any (inputs, script/run/py/go, env, timeout).
  • Updated parseMCPScriptsMap and mergeMCPScripts to use the new helper instead of duplicating the parsing block.
  • Consolidated the uint64 timeout safe-conversion into one place.
Show a summary per file
File Description
pkg/workflow/mcp_scripts_parser.go Extracts a single-tool parser helper and reuses it in both map parsing and import merging to remove duplication.

Copilot's findings

Tip

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

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

Comment thread pkg/workflow/mcp_scripts_parser.go Outdated
case uint64:
toolConfig.Timeout = typeutil.SafeUint64ToInt(t) // Safe conversion to prevent overflow (alert #413, #414)
case float64:
toolConfig.Timeout = int(t)
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

The float64 timeout branch converts via int(t) without any bounds checking. Since mergeMCPScripts uses json.Unmarshal into map[string]any, numeric values in imported configs will typically arrive as float64, so extremely large values can yield implementation-defined results (wrap/undefined) instead of safely falling back to the default. Consider validating the range (e.g., 0 <= t <= maxInt) before converting, and keep the default + log a warning when out of range.

Suggested change
toolConfig.Timeout = int(t)
maxInt := int(^uint(0) >> 1)
if t != t || t < 0 || t > float64(maxInt) {
mcpScriptsLog.Printf("Warning: invalid timeout value %v for tool %q, keeping default timeout (60s)", t, toolName)
} else {
toolConfig.Timeout = int(t)
}

Copilot uses AI. Check for mistakes.
Comment thread pkg/workflow/mcp_scripts_parser.go Outdated
}

// parseMCPScriptsMap parses mcp-scripts configuration from a map.
// This is the shared implementation used by both ParseMCPScripts and extractMCPScriptsConfig.
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

The comment says parseMCPScriptsMap is shared by ParseMCPScripts and extractMCPScriptsConfig, but there is no ParseMCPScripts function in this package/repo. This makes the comment misleading; consider updating it to reference the actual callers (e.g. extractMCPScriptsConfig and/or any other current entry points).

Suggested change
// This is the shared implementation used by both ParseMCPScripts and extractMCPScriptsConfig.
// It is used by extractMCPScriptsConfig to convert frontmatter into an MCPScriptsConfig.

Copilot uses AI. Check for mistakes.
…traction

Generated by Design Decision Gate workflow to document the architectural
decision to extract a shared parsing helper to eliminate duplication.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Commit pushed: de2659d

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions
Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (108 new lines in pkg/workflow/) but does not have a linked Architecture Decision Record (ADR).

AI has analyzed the PR diff and generated a draft ADR to help you get started:

📄 Draft ADR: docs/adr/28897-extract-parsemcpscripttoolconfig-helper.md

What to do next

  1. Review the draft ADR committed to your branch — it was generated from the PR diff
  2. Complete the missing sections — add context the AI couldn't infer, refine the decision rationale, and list real alternatives you considered
  3. Commit the finalized ADR to docs/adr/ on your branch
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-28897: Extract parseMCPScriptToolConfig Helper

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

Why ADRs Matter

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say 'I'll deal with this later.' Deferring decisions corroded my ability to think clearly."

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.


📋 What the draft ADR captures

The generated draft covers:

  • Context: Two identical ~100-line parsing blocks existed in parseMCPScriptsMap and mergeMCPScripts; the uint64 overflow bug (alerts [Custom Engine Test] Test Pull Request - Custom Engine Safe Output #413 and [Custom Engine Test] Test Issue Created by Custom Engine #414) had to be patched independently at both sites, demonstrating a real maintenance hazard.
  • Decision: Extract parseMCPScriptToolConfig(toolName string, toolMap map[string]any) *MCPScriptToolConfig as the single authoritative parsing path for MCPScriptToolConfig from raw maps.
  • Alternatives Considered: (1) Accept duplication — rejected because the drift already caused a real defect; (2) Interface/strategy pattern — rejected as over-engineered for a stable, well-defined config format.
  • Consequences: Single canonical parsing path with one edit point; trade-off is one level of indirection and slightly harder isolated testing.
📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number (e.g., 28897-extract-parsemcpscripttoolconfig-helper.md for PR #28897).

🔒 This PR cannot merge until an ADR is linked in the PR body.

References: §25047928528

Note

🔒 Integrity filter blocked 1 item

The following item was blocked because it doesn't meet the GitHub integrity level.

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · ● 148.9K ·

@github-actions
Copy link
Copy Markdown
Contributor

🛠️ Agentic Maintenance updated this pull request branch.

View workflow run

@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot review all comments

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 28, 2026

@copilot review all comments

Addressed both review comments in 661c17a:

  • float64 bounds check (line 182): added NaN/negative/overflow guard — out-of-range values now log a warning and keep the 60 s default, consistent with the string branch.
  • Misleading comment (line 196): updated to reference the actual caller (extractMCPScriptsConfig) rather than the non-existent ParseMCPScripts.

@pelikhan pelikhan merged commit 7329b8b into main Apr 28, 2026
@pelikhan pelikhan deleted the copilot/refactor-extract-parsemcpscripttoolconfig-helper branch April 28, 2026 10:52
Copilot stopped work on behalf of pelikhan due to an error April 28, 2026 10:52
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.

refactor: extract parseMCPScriptToolConfig helper to remove duplication in mcp_scripts_parser.go

3 participants