Skip to content

Fix: send denial/error response when broadcast permission/tool handler throws synchronously (ports upstream v3 sync)#185

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/fix-github-actions-workflow-again
Draft

Fix: send denial/error response when broadcast permission/tool handler throws synchronously (ports upstream v3 sync)#185
Copilot wants to merge 5 commits intomainfrom
copilot/fix-github-actions-workflow-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

Original prompt

Fix the failing GitHub Actions workflow Java SDK Tests
Analyze the workflow logs, identify the root cause of the failure, and implement a fix.
Job ID: 66482073100
Job URL: https://github.com/copilot-community-sdk/copilot-sdk-java/actions/runs/22910533522/job/66482073100


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@edburns
Copy link
Collaborator

edburns commented Mar 10, 2026

@copilot I observe two of the tests during the Build & Test workflow had errors. Not failures. errors:

Error:  Tests run: 9, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 77.35 s <<< FAILURE! -- in com.github.copilot.sdk.PermissionsTest
Error:  com.github.copilot.sdk.PermissionsTest.testShouldHandlePermissionHandlerErrorsGracefully(TestInfo) -- Time elapsed: 61.06 s <<< ERROR!
Error:  Tests run: 5, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 127.9 s <<< FAILURE! -- in com.github.copilot.sdk.ErrorHandlingTest
Error:  com.github.copilot.sdk.ErrorHandlingTest.testShouldHandlePermissionHandlerErrorsGracefully_deniesPermission -- Time elapsed: 61.03 s <<< ERROR!

These appear related to the changes.

Please investigate and make necessary changes.

Attached is the complete log for the Build & Test run that failed. This is also at https://github.com/copilot-community-sdk/copilot-sdk-java/actions/runs/22910533522/job/66482073100 .

20260310-1655-UTC+1.txt

…on bug in broadcast events

The PR ports 24 upstream commits through 9a0a1a5 adding:
- Protocol v3 with v2 backward compatibility
- BYOK model listing (onListModels hook)
- Agent pre-selection (SessionConfig.setAgent)
- onEvent handler (registered before session.create RPC)
- Register-before-RPC session insertion
- 9 new broadcast event types (ExternalToolRequestedEvent, etc.)
- CopilotSession.log() API

Bug fix: when permission/tool broadcast handlers throw synchronously,
catch blocks now send denial/error responses to unblock the CLI server.
Without this fix, sendAndWait() would timeout waiting for SessionIdleEvent.

Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
@edburns
Copy link
Collaborator

edburns commented Mar 10, 2026

Please try again to fix the errors I reported when running the "Build & Test" workflow.

@edburns
Copy link
Collaborator

edburns commented Mar 10, 2026

@copilot Please try again to fix the errors I reported when running the "Build & Test" workflow.

…dAsync

The v3 CLI (1.0.3-0) does not recognize "denied-could-not-request-from-user"
as a valid permission result kind. Use the correct constant
PermissionRequestResultKind.DENIED_COULD_NOT_REQUEST_FROM_USER
which maps to "denied-no-approval-rule-and-could-not-request-from-user".

This fixes the CI failures in:
- PermissionsTest.testShouldHandlePermissionHandlerErrorsGracefully
- ErrorHandlingTest.testShouldHandlePermissionHandlerErrorsGracefully_deniesPermission

Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 10, 2026

Please try again to fix the errors I reported when running the "Build & Test" workflow.

Fixed in commit 5be7430. The root cause was that executePermissionAndRespondAsync was sending kind: "denied-could-not-request-from-user" when the permission handler throws, but CLI v3 (1.0.3-0, used in CI) only recognizes "denied-no-approval-rule-and-could-not-request-from-user" as a valid denial kind — causing "Unhandled permission result kind" errors and 61-second timeouts. Changed both error-path denial kinds to use PermissionRequestResultKind.DENIED_COULD_NOT_REQUEST_FROM_USER (the pre-existing constant with the correct value). All tests now pass with the v3 CLI.

@copilot Please try again to fix the errors I reported when running the "Build & Test" workflow.

Fixed in commit 5be7430. The executePermissionAndRespondAsync method was sending an unrecognized permission denial kind to CLI v3. See the other comment for details.

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:

  • checkstyle.org
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.24.2/x64/codeql/tools/linux64/java/bin/java /opt/hostedtoolcache/CodeQL/2.24.2/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.24.2/x64/codeql/xml/tools/xml-extractor.jar --fileList=/tmp/codeql-scratch-a0b8ba07f7cabbfc/dbs/java/working/files-to-index12501866053070594088.list --sourceArchiveDir=/tmp/codeql-scratch-a0b8ba07f7cabbfc/dbs/java/src --outputDir=/tmp/codeql-scratch-a0b8ba07f7cabbfc/dbs/java/trap/java git ndor/bin/which --show-toplevel which ich urin-17-jdk-amd64/lib/jspawnhelper rev-�� --show-toplevel echo va/copilot-sdk-java/target/copilot-sdk/node_modules/.bin/node ot-sdk/nodejs/nogit urin-17-jdk-amd6diff ot-sdk/test/harn--name-only sh (dns block)
  • https://api.github.com/copilot_internal/user
    • Triggering command: /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot (http block)
    • Triggering command: /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/nodejs/node_modules/@github/copilot-linux-x64/copilot /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/nodejs/node_modules/@github/copilot-linux-x64/copilot --server --no-auto-update --log-level info --stdio -x64/copilot tnet/tools/which --depth 1 ndor/bin/which git -C /tmp/copilot-test-work-5217687989483549252 remote ava/target/copilot-sdk/node_modules/.bin/node om/github/copilogit /copilot which which (http block)
    • Triggering command: /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/nodejs/node_modules/@github/copilot-linux-x64/copilot /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/nodejs/node_modules/@github/copilot-linux-x64/copilot --server --no-auto-update --log-level info t-work-5217687989483549252 remote which tsx server.ts va/copilot-sdk-jshared k/copilot-sdk-java/copilot-sdk-j/tmp/copilot-test-work-9251489182800598353 which gh node git 0/x64/bin/git copilot/fix-githwhich bash ache/Java_Temurin-Hotspot_jdk/17--show-toplevel which (http block)
  • https://api.github.com/repos/github/copilot-cli/releases/latest
    • Triggering command: /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot version (http block)

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

Copilot AI and others added 2 commits March 11, 2026 08:48
…(ported from #185)

Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Copilot AI added a commit that referenced this pull request Mar 11, 2026
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