Skip to content

slash_command activation fails for bot comments that append metadata after a newline #21816

@jaroslawgajewski

Description

@jaroslawgajewski

Summary

When a bot actor posts a slash command comment with attribution metadata appended after a newline (e.g. /command\n> Generated by ...), the compiled pre_activation job never activates — even if the bot is correctly listed under bots:.

Root Cause

The compiler generates the following activation condition for slash_command:

startsWith(github.event.comment.body, '/command ')   # trailing space required
|| github.event.comment.body == '/command'           # exact match only

Bot-authored comments routinely append attribution metadata after a newline:

/command
> Generated by [Workflow Name](...)
<!-- gh-aw-agentic-workflow: ... -->

The comment body is /command\n> Generated by.... This satisfies neither condition:

startsWith('/command ') → false (newline, not space, follows the command)
== '/command' → false (body has extra content)

The check_membership step passes (bot is in GH_AW_ALLOWED_BOTS), but check_command_position fails, so activated is never true. The workflow silently skips with no error.

Expected Behavior

A comment whose first line is exactly the slash command should trigger activation, regardless of what follows on subsequent lines. The command-matching logic should strip or ignore everything after the first newline before comparing.

Suggested Fix

In check_command_position.cjs, normalize the body before matching:

const firstLine = body.split('\n')[0].trim();
// then match against firstLine instead of body

Or in the generated if: expression:

startsWith(github.event.comment.body, '/command\n')
|| startsWith(github.event.comment.body, '/command ')
|| github.event.comment.body == '/command'

The cleanest fix is normalizing in check_command_position.cjs so the generated YAML expression doesn't need to enumerate all possible trailing characters.

Reproduction

Create a workflow with slash_command: "command" and bots: [my-bot]
Have my-bot post a comment: /command\n> attribution text
Observe: pre_activation job runs but activated output is false; downstream jobs are skipped

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions