Skip to content

fix(guardrails): merge guard blocks a reply that quotes a merge command in backticks #18900

Description

@kyle-sexton

Summary

The guardrails merge guard refused a gh api graphql review-thread reply because the reply body quoted a merge command inside markdown backticks. The command merged nothing.

Steps to reproduce

Run a GraphQL mutation whose body text contains a backticked merge command, for example an addPullRequestReviewThreadReply whose body includes the text `gh pr merge 42`.

Expected

The guard passes it: the command text is inside a quoted argument (hook-precision rule 2 in the guard's header), and no merge path runs.

Actual

The guard blocks it as a merge whose target it cannot resolve (the backtick branch that fails closed).

Seen with guardrails 4.0.0 block-unresolved-pr-merge.sh on 2026-11-24 while replying on claude-code-plugins#18835. Whether the renamed merge-guard.sh from #18835 keeps the behavior is UNVERIFIED.

Suggested fix location

The target-resolution check that treats a backtick as an unresolvable target: apply it only at a command position, not inside a quoted argument, with a test for a backticked merge command in a GraphQL body.

Activity

  1. added
    needs-triage
    on Nov 24, 2026
  2. github-actions commented on Nov 24, 2026

    @github-actions
    Contributor

    Size: Small
    Complexity: Medium
    Uncertainty: Knowable
    Flags: intent
    Blocked by: none
    Blast radius: the guardrails merge guard (plugins/guardrails/hooks/merge-guard.sh) and its tests; every Bash command in sessions running the plugin passes through it.
    Reversible: yes; revert the change to the hook and its tests.
    Claims checked:

    1. The guard blocks a merge-shaped command with a backtick even inside a quoted argument: held, plugins/guardrails/hooks/merge-guard.sh:53-62. The header says this is deliberate ("a backtick in a quoted --body is refused too; pass such a body with --body-file").
    2. The script is named block-unresolved-pr-merge.sh: not held in this checkout; it is now plugins/guardrails/hooks/merge-guard.sh. The renamed guard still has the behavior, so the issue's UNVERIFIED point is answered.
    3. The header carries a hook-precision rule 2 that says quoted text passes: not verified. The header says the opposite for backticks, so the issue's expectation conflicts with the documented design.
      Open questions:
    4. Should the guard stop treating a backtick inside a quoted argument as unresolvable? The header says the pre-filter tracks no quotes on purpose, because a quote tracker can be fooled by a comment or heredoc apostrophe. Quote tracking would weaken a fail-closed security choice.
      RECOMMENDED: keep the fail-closed behavior and document --body-file for GraphQL and REST bodies. If the owner wants the narrower rule, accept it only if a test shows 5echo 0`` style substitutions at command position are still blocked. Basis: merge-guard.sh:53-62.
      To answer, post a comment that starts with this line:
    **Decision recorded.** <answer>
    

    Automated triage. A maintainer reviews it.

  3. added
    needs-owner-decision
    on Nov 24, 2026
  4. melodic-automation-lanes commented on Nov 24, 2026

    @melodic-automation-lanes
    Contributor

    The triage verdict left this issue at needs-owner-decision:

    • flagged: intent
    • held by needs-owner-decision
    • no lanes App verdict comment shows whether an earlier verdict was flagged

    Reason: intent

  5. melodic-automation-lanes commented on Nov 24, 2026

    @melodic-automation-lanes
    Contributor

    Refinement. A read-only run explored this repository, searched its issues and pull requests, and read the allowed docs to draft what follows. On an issue a listed human filed, it counts as the issue's spec once posted, while unedited; it is still model text, so check it.

    Intended outcome: Either keep the fail-closed backtick refusal and document --body-file for GraphQL and REST reply bodies, or narrow the refusal to command position with tests; the owner has not chosen.

    Related work

    Open questions

    1. Should the guard keep refusing a backtick inside a quoted argument on a merge-shaped command, as designed, or allow it?
      RECOMMENDED: Keep the fail-closed behavior. Document --body-file for GraphQL and REST bodies in the refusal message and the header. This is a decision for the owner. Basis: plugins/guardrails/hooks/merge-guard.sh:53-62
    2. If the owner wants the narrower rule, what quote handling is acceptable, given the header says the pre-filter tracks no quotes on purpose because a comment or heredoc apostrophe can fool a quote tracker?
      RECOMMENDED: Accept it only if tests show that 5echo 0`` style substitutions at command position, and merge text inside backticks, are still blocked. Also require a passing test for a backticked gh pr merge 42 inside a GraphQL body. Basis: plugins/guardrails/hooks/merge-guard.sh:57-62
    3. Is the issue's claim that hook-precision rule 2 says quoted text passes correct for backticks?
      RECOMMENDED: No. The header applies rule 2 to the matched merge paths (lines 20-21) and then makes an explicit exception for backticks (lines 53-62). Treat the issue as a request to change a documented design, not as a bug. Basis: plugins/guardrails/hooks/merge-guard.sh:20-21

    Sources read

    • /home/runner/work/claude-code-plugins/claude-code-plugins/.base/plugins/guardrails/hooks/merge-guard.sh:48-62: an unresolvable target fails closed. A merge-shaped Bash command that holds a backtick is blocked, and a backtick in a quoted --body is refused too, so pass the body with --body-file.
    • /home/runner/work/claude-code-plugins/claude-code-plugins/.base/plugins/guardrails/hooks/merge-guard.sh:20-21: merge paths match at a command position, never inside a quoted argument (hook-precision rule 2).

    To answer, post a comment that starts with this line:

    **Decision recorded.** <answer>
    

    Automated refinement by the lanes App. Answer with a comment whose first line is **Decision recorded.**.

  6. kyle-sexton commented on Nov 25, 2026

    @kyle-sexton
    MemberAuthor

    Owner decision on this issue (option A), given in session 2026-11-25T03:15Z.

    verbatim: /session-flow:go-with-recommendations, accepting option (A) as recommended.

    Options shown: (A) keep the guard and document that a reply or comment quoting a merge command goes through --body-file (or -F body=@file for gh api), which the guard does not scan as a command line; (B) apply the backtick check only at a command position, with a test for a quoted merge command in a GraphQL body; (C) no change.

    Decision: (A). The guard keeps failing closed on a backticked merge command in the command text, and this issue's expected behavior becomes "the documented --body-file route passes". Revisit (B) only if quoting a command in a reply keeps recurring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-owner-decisionneeds-triage

    Type

    Fields

    Work status

    needs-owner-decision

    Priority

    medium

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions