From cdfeed839b94bb83baefd23d406823cf8c86abe9 Mon Sep 17 00:00:00 2001 From: Egor Greb Date: Wed, 3 Jun 2026 17:35:03 +0200 Subject: [PATCH] Allow award_emoji API calls through PreToolUse hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The hook regex matched any glab api path containing merge_requests/.../notes, which incidentally blocked the award emoji (reactions) endpoints — e.g. notes/:id/award_emoji used by review bots as a re-review trigger. The deny message redirects to glab-discussion, which has no reactions command, leaving agents at a dead end. Reactions are not discussion CRUD, so let them pass through to raw glab api instead of blocking them. Fixes #1 Co-Authored-By: Claude Opus 4.8 (1M context) --- .../claude-code/hooks/block-glab-api-discussions.sh | 5 ++++- .../claude-code/hooks/test-block-glab-api-discussions.sh | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/coding-agent-plugins/claude-code/hooks/block-glab-api-discussions.sh b/coding-agent-plugins/claude-code/hooks/block-glab-api-discussions.sh index 4b93fb3..ccadd68 100755 --- a/coding-agent-plugins/claude-code/hooks/block-glab-api-discussions.sh +++ b/coding-agent-plugins/claude-code/hooks/block-glab-api-discussions.sh @@ -9,7 +9,10 @@ fi REASON="Reading or writing MR discussions/notes via \`glab\` is blocked (matched: \`glab api .../discussions|notes\`, \`glab mr view --comments\`, or \`glab mr note\`). Use the \`glab-discussion\` CLI instead: \`glab-discussion read|write|diff|resolve|edit|delete\`. Run \`glab-discussion --help\` for usage, or load the \`glab-discussion\` skill." -if printf '%s' "$CMD" | grep -qE 'glab[[:space:]]+api\b.*merge_requests[^"'"'"']*/(discussions|notes)' \ +# Award emoji (reactions) live under the notes URL path but are not discussion +# CRUD, and glab-discussion has no replacement command — let them through. +if { printf '%s' "$CMD" | grep -qE 'glab[[:space:]]+api\b.*merge_requests[^"'"'"']*/(discussions|notes)' \ + && ! printf '%s' "$CMD" | grep -qE 'glab[[:space:]]+api\b.*merge_requests[^"'"'"']*/award_emoji\b'; } \ || printf '%s' "$CMD" | grep -qE 'glab[[:space:]]+mr[[:space:]]+view\b.*--comments\b' \ || printf '%s' "$CMD" | grep -qE 'glab[[:space:]]+mr[[:space:]]+note\b'; then jq -n --arg reason "$REASON" '{ diff --git a/coding-agent-plugins/claude-code/hooks/test-block-glab-api-discussions.sh b/coding-agent-plugins/claude-code/hooks/test-block-glab-api-discussions.sh index 030a353..2b7d1c5 100755 --- a/coding-agent-plugins/claude-code/hooks/test-block-glab-api-discussions.sh +++ b/coding-agent-plugins/claude-code/hooks/test-block-glab-api-discussions.sh @@ -68,6 +68,12 @@ run_case ALLOW 'glab mr create' run_case ALLOW 'glab mr approve 42' run_case ALLOW 'glab mr todo 42' +# ---------------- ALLOW: award emoji (reactions) under notes ---------------- +run_case ALLOW 'glab api projects/123/merge_requests/5/notes/99/award_emoji -X POST -f name=recycle' +run_case ALLOW 'glab api "projects/:id/merge_requests/20/notes/1996757/award_emoji" -f name=thumbsup' +run_case ALLOW 'glab api projects/123/merge_requests/5/notes/99/award_emoji/7 -X DELETE' +run_case ALLOW 'glab api projects/mygroup%2Fmyrepo/merge_requests/42/award_emoji' + # ---------------- ALLOW: unrelated glab api calls ---------------- run_case ALLOW 'glab api projects/mygroup%2Fmyrepo/merge_requests/42' run_case ALLOW 'glab api "projects/mygroup%2Fmyrepo"'