Fix command matching and commenter identification in workflow triggers#497
Closed
kelos-bot[bot] wants to merge 2 commits intomainfrom
Closed
Fix command matching and commenter identification in workflow triggers#497kelos-bot[bot] wants to merge 2 commits intomainfrom
kelos-bot[bot] wants to merge 2 commits intomainfrom
Conversation
The /squash-commits and /reset-worker workflows had two issues: 1. The job-level `if` condition used `contains()` which matches the command text anywhere in a comment body, causing false triggers when bots or other comments incidentally mention the command text. Add a `sender.type == 'User'` check to skip bot-triggered events at the job level, and validate in the gate step that the command appears at the start of a line using a regex check. 2. The commenter identification used `comment.user.login` or `review.user.login` but did not consider `sender.login` from the event payload, which is the most reliable source for the actor who triggered the event. Add `context.payload.sender.login` as the primary fallback. Fixes #496 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".github/workflows/squash-kelos-worker-commits.yaml">
<violation number="1" location=".github/workflows/squash-kelos-worker-commits.yaml:28">
P2: Fail-open bot filter: `|| 'User'` fallback defaults unknown sender types to `'User'`, bypassing the bot check. If `sender.type` is unexpectedly null/empty, the job runs anyway — contradicting the security intent. Remove the fallback so unknown sender types are rejected (fail-closed).</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Remove the `|| 'User'` fallback from the sender.type check so that unknown or missing sender types are rejected instead of defaulting to 'User' and bypassing the bot filter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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.
Summary
sender.type == 'User'check to skip bot-triggered events at the jobiflevel in both/squash-commitsand/reset-workerworkflowscontext.payload.sender.loginas the primary source for commenter identification, withcomment.user.loginandreview.user.loginas fallbacksFixes #496
Test plan
/squash-commitscommand works when issued by an admin at the start of a comment on a PR/squash-commitstext appearing mid-comment (e.g. in a triage report) does not trigger the workflow/squash-commitsor/reset-workerare skipped at the job level/reset-workercommand works when issued by an admin at the start of a comment🤖 Generated with Claude Code
Summary by cubic
Prevents false triggers and fixes commenter detection in the /squash-commits and /reset-worker workflows. Commands now only run from user comments that start with the command text, with a fail-closed bot filter. Fixes #496.
Written for commit 56fa174. Summary will update on new commits.