fix: guardrail hooks fail-open instead of fail-closed#580
Merged
Conversation
Remove `set -e` from _common.sh and add `trap 'exit 0' ERR` so that unexpected errors (empty input, malformed JSON, non-bash tool payloads) result in allowing the tool call rather than blocking it. Previously, when non-bash MCP tools (e.g. Zendesk, GitHub MCP) triggered the preToolUse hooks, the script could error out before reaching the 'toolName != bash' check. The CLI interprets hook errors as denials, which blocked ALL tool calls — including reads, shell commands, and MCP. Also adds early JSON validation: if input is empty or invalid JSON, exit immediately with allow. Fixes gm3dmo#579 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The guardrail hooks in
copilot-plugin/hooks/_common.shuseset -e, which causes the script to exit with a non-zero code if anything unexpected happens before reaching thetoolName != bash → exit 0check.When the Copilot CLI invokes these hooks for non-bash tools (e.g. Zendesk MCP, GitHub MCP, or any other MCP tool call), the hook errors out rather than returning a clean exit. The CLI interprets a hook error as a denial, which blocks all tool calls — including reads, shell commands, and MCP calls.
Fix
set -etrap 'exit 0' ERR— fail-open on unexpected errorsexit 0immediatelyThese hooks only guard against destructive bash operations — they should never interfere with non-bash tools.
Testing
Fixes #579