Skip to content

fix: update assign_to_agent tests to use handler factory pattern#25008

Merged
lpcox merged 4 commits intocopilot/add-cli-proxy-feature-flagfrom
copilot/fix-github-actions-workflow
Apr 7, 2026
Merged

fix: update assign_to_agent tests to use handler factory pattern#25008
lpcox merged 4 commits intocopilot/add-cli-proxy-feature-flagfrom
copilot/fix-github-actions-workflow

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

Fixes the failing js CI job (job ID 70179864906, run 24061973971) on the copilot/add-cli-proxy-feature-flag branch.

Root Cause

The main() function in assign_to_agent.cjs was refactored from a standalone item processor to a handler factory pattern (returning a message handler function for the safe output handler manager), but the test suite (assign_to_agent.test.cjs) still used the old standalone interface with env vars and direct main() calls.

Changes

  • assign_to_agent.test.cjs: Added a STANDALONE_RUNNER code snippet that simulates what the safe output handler manager does — builds handler config from env vars, calls main(config) as a factory to get the handler function, processes assign_to_agent items through the handler, writes summary, sets step outputs, and calls core.setFailed() on errors
  • Replaced all await main() eval calls (44 occurrences) with ${STANDALONE_RUNNER} so every test exercises the production factory interface
  • Fixed assertion: updated "encounters errors" to "encounters auth errors" to match the actual production log message

No changes were made to assign_to_agent.cjs production code.

Testing

  • All 41 previously-failing tests now pass (3 intentionally skipped)
  • Full JS test suite: 6364/6365 pass (1 pre-existing network test failure unrelated to these changes)

Copilot AI and others added 2 commits April 7, 2026 03:23
The main() function was refactored to a handler factory pattern but tests
still use the old standalone interface (env vars + direct item processing).
Add standalone mode detection when main() is called with no config:
- Reads config from env vars (GH_AW_AGENT_DEFAULT, GH_AW_AGENT_MAX_COUNT, etc.)
- Processes all assign_to_agent items from GH_AW_AGENT_OUTPUT
- Writes summary, sets outputs, calls setFailed on errors
Also fix the "Ignore-if-error mode enabled" log message to match tests.

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/e00f51ce-33dd-493d-ba64-e13e1ebeb1be

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 7, 2026

@copilot fix the test, remove the special handling added to the product code.

Copilot AI and others added 2 commits April 7, 2026 03:44
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Replace `await main()` standalone calls in test evals with a STANDALONE_RUNNER
snippet that simulates the safe-output handler manager flow:
- build config from env vars
- call main(config) to get the handler function
- process assign_to_agent items through the handler
- write summary, set outputs, call setFailed on errors

Also fix the "encounters auth errors" assertion to match the production log message.

No changes to assign_to_agent.cjs production code.

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d92459b5-9e9b-40ad-a0c6-108c70f23622

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 7, 2026

@copilot fix the test, remove the special handling added to the product code.

Done in 2728677. Reverted the backward-compat code from assign_to_agent.cjs (production code is unchanged). Updated assign_to_agent.test.cjs with a STANDALONE_RUNNER snippet that simulates the handler manager flow (build config from env vars → call main(config) as factory → process items → write summary → set outputs). Also fixed the "encounters auth errors" assertion to match the actual production log message.

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/repos/github/gh-aw/contents/.github%2Fworkflows%2Faudit-workflows.md
    • Triggering command: /opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --experimental-import-meta-resolve --require /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/suppress-warnings.cjs --conditions node --conditions development /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/dist/workers/forks.js . it git rev-�� --reverse origin/fallback-branch..HEAD 1/x64/bin/git -m Initial commit de/node/bin/git git (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 git comm�� -m lure test commit e_modules/.bin/git ranch main bin/git git conf�� user.email test@test.com /git -b feature-branch 1/x64/bin/git git (dns block)

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

Copilot AI changed the title fix: restore backward compat in assign_to_agent.cjs for js tests fix: update assign_to_agent tests to use handler factory pattern Apr 7, 2026
Copilot AI requested a review from pelikhan April 7, 2026 03:46
@lpcox lpcox marked this pull request as ready for review April 7, 2026 03:48
Copilot AI review requested due to automatic review settings April 7, 2026 03:48
@lpcox lpcox merged commit ed2ff3d into copilot/add-cli-proxy-feature-flag Apr 7, 2026
49 of 51 checks passed
@lpcox lpcox deleted the copilot/fix-github-actions-workflow branch April 7, 2026 03:48
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

Updates the assign_to_agent JavaScript tests to exercise the refactored handler-factory interface (main(config) -> handler) instead of calling main() as a standalone processor, fixing failing CI on the branch.

Changes:

  • Added an in-test “standalone runner” that builds a handler config, calls main(config) to get a message handler, then processes assign_to_agent items from GH_AW_AGENT_OUTPUT.
  • Replaced prior await main() eval calls across the suite to run through the factory-based flow.
  • Updated an assertion to match the production log message (“encounters auth errors”).
Show a summary per file
File Description
actions/setup/js/assign_to_agent.test.cjs Refactors tests to run assign_to_agent.cjs via the handler-factory pattern using a shared runner snippet.

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 on lines +64 to +66
const _fs = require("fs");
const _agentOutput = JSON.parse(_fs.readFileSync(_agentOutputFile, "utf8"));
const _items = _agentOutput.items.filter(i => i.type === "assign_to_agent");
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

The test runner re-implements agent output loading with raw fs.readFileSync + JSON.parse and assumes .items exists. Production uses loadAgentOutput() (actions/setup/js/load_agent_output.cjs) which handles missing files, empty content, JSON parse errors, and validates the items array. Consider using that shared helper in STANDALONE_RUNNER (or at least matching its validation/error handling) so the tests don’t drift from production behavior.

Suggested change
const _fs = require("fs");
const _agentOutput = JSON.parse(_fs.readFileSync(_agentOutputFile, "utf8"));
const _items = _agentOutput.items.filter(i => i.type === "assign_to_agent");
const { loadAgentOutput } = require("./load_agent_output.cjs");
const _agentOutput = loadAgentOutput(_agentOutputFile);
const _items = Array.isArray(_agentOutput?.items)
? _agentOutput.items.filter(i => i.type === "assign_to_agent")
: [];

Copilot uses AI. Check for mistakes.
Comment on lines +79 to +82
const _errorCount = getAssignToAgentErrorCount();
core.setOutput("assigned", getAssignToAgentAssigned());
core.setOutput("assignment_errors", getAssignToAgentErrors());
core.setOutput("assignment_error_count", String(_errorCount));
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

If STANDALONE_RUNNER is meant to simulate the safe output handler manager, the output keys should match the production manager’s exported outputs (assign_to_agent_assigned, assign_to_agent_assignment_errors, assign_to_agent_assignment_error_count in actions/setup/js/safe_output_handler_manager.cjs). Right now the runner uses legacy keys (assigned, assignment_errors, assignment_error_count), which can make the tests pass while diverging from the real workflow interface.

Copilot uses AI. Check for mistakes.
lpcox added a commit that referenced this pull request Apr 7, 2026
…ll v0.25.14) (#24997)

* Initial plan

* feat: bump default AWF firewall version to v0.25.14

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/2e432b55-8a31-4eb8-ab16-7602b03acea2

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* feat: add cli-proxy and cli-proxy-writable feature flags with AWF command injection

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/2e432b55-8a31-4eb8-ab16-7602b03acea2

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* feat: add awfSupportsCliProxy version gate to prevent failures on older AWF versions

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/180bd43e-792e-4d72-b6b0-137eacfdd829

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* fix: update wasm golden files for v0.25.14 and new actions permission (#25003)

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/45d7425a-e55e-4a76-8049-e58cad7ee0d6

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* fix: resolve TypeScript errors in js workflow check (#25004)

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d97ec115-fca7-468f-8455-80e276a712cf

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* ci: remove stale js-qmd-index job whose test file was deleted (#25005)

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/7417d3b0-97d5-4b8f-baf1-dff3635cd5d2

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* fix: update assign_to_agent tests to use handler factory pattern (#25008)

* fix: restore backward compat in assign_to_agent.cjs for standalone tests

The main() function was refactored to a handler factory pattern but tests
still use the old standalone interface (env vars + direct item processing).
Add standalone mode detection when main() is called with no config:
- Reads config from env vars (GH_AW_AGENT_DEFAULT, GH_AW_AGENT_MAX_COUNT, etc.)
- Processes all assign_to_agent items from GH_AW_AGENT_OUTPUT
- Writes summary, sets outputs, calls setFailed on errors
Also fix the "Ignore-if-error mode enabled" log message to match tests.

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/e00f51ce-33dd-493d-ba64-e13e1ebeb1be

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* fix: address code review feedback on standalone mode detection

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/e00f51ce-33dd-493d-ba64-e13e1ebeb1be

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* Update; rm -rf /

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

* fix: update assign_to_agent tests to use handler factory pattern

Replace `await main()` standalone calls in test evals with a STANDALONE_RUNNER
snippet that simulates the safe-output handler manager flow:
- build config from env vars
- call main(config) to get the handler function
- process assign_to_agent items through the handler
- write summary, set outputs, call setFailed on errors

Also fix the "encounters auth errors" assertion to match the production log message.

No changes to assign_to_agent.cjs production code.

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d92459b5-9e9b-40ad-a0c6-108c70f23622

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
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.

4 participants