Skip to content

fix(ci): store regex in variables to fix notify-parent parse error - #8

Merged
mateodelnorte merged 1 commit into
mainfrom
fix/notify-parent-regex
Feb 19, 2026
Merged

mateodelnorte merged 1 commit into
mainfrom
fix/notify-parent-regex

Conversation

@mateodelnorte

@mateodelnorte mateodelnorte commented Feb 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Stores regex patterns in bash variables before using them in [[ =~ ]] tests
  • Fixes bash parse error: ( in [:(] character class was interpreted as unmatched subshell opener
  • Error: unexpected EOF while looking for matching ')' (exit code 2)
  • Broken since cascading notification support was added

Root cause

# Broken — bash parses ( as subshell opener before regex engine sees it
if [[ "$MSG" =~ ^feat[:(] ]]; then ...

# Fixed — variable content passes directly to regex engine
re_feat='^feat[:(]'
if [[ "$MSG" =~ $re_feat ]]; then ...

Context

  • Part of [[tasks/meta-64]] / [[incidents/notify-parent-broken]]
  • Same fix applied to all 5 affected child repos

Test plan

  • Workflow passes on next push to main after merge

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Improved automated workflow detection and message-type inference for clearer, more maintainable CI behavior.
  • Chores
    • Standardized workflow outputs and environment variable usage for more consistent automation and payload handling.

Note: This release contains no user-facing changes.

@coderabbitai

coderabbitai Bot commented Feb 18, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉


Walkthrough

A GitHub Actions workflow was updated to set event/payload environment variables, centralize the event name into EVENT_NAME, introduce a write_output helper for GITHUB_OUTPUT, replace inline echo/output writes with helper calls, and replace inline regex literals with named regex variables for commit-message type inference.

Changes

Cohort / File(s) Summary
Workflow update
.github/workflows/notify-parent.yml
Added environment variables for event and payload metadata; introduced a write_output helper to emit GITHUB_OUTPUT entries; centralized event handling via EVENT_NAME; replaced inline echo output writes with write_output calls in both repository_dispatch and other paths; extracted inline regexes into named variables (re_feat, re_fix, re_chore, re_docs, re_test, re_refactor) for message-type inference; retains type=other fallback.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I hopped through YAML, tidy and bright,
Named my regexes, set vars just right,
Outputs bundled with a gentle shout,
Events now routed without a doubt,
A crunchy carrot of clarity tonight.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing a bash parse error in the notify-parent workflow by storing regex patterns in variables instead of using them inline.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/notify-parent-regex

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented Feb 18, 2026

Copy link
Copy Markdown

Greptile Summary

Fixed bash parse error in notify-parent workflow by storing regex patterns in variables before using them in [[ =~ ]] tests. The ( character in [:(] character classes was being incorrectly interpreted as a subshell opener, causing "unexpected EOF while looking for matching ')'" errors.

  • Extracted 6 regex patterns (^feat[:(], ^fix[:(], etc.) into variables on lines 47-48
  • Updated all conditional tests to reference these variables instead of inline patterns
  • Same logical behavior, now with correct bash parsing

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix addresses a critical parse error with a well-established bash best practice (storing regex in variables before use in =~ tests). The change is minimal, localized to one workflow file, preserves all existing logic, and follows the exact pattern recommended in bash documentation for avoiding parse ambiguities
  • No files require special attention

Important Files Changed

Filename Overview
.github/workflows/notify-parent.yml Fixed bash parse error by storing regex patterns in variables before using them in conditional tests

Last reviewed commit: a6bc980

@mateodelnorte
mateodelnorte force-pushed the fix/notify-parent-regex branch from a6bc980 to 7561bbe Compare February 18, 2026 23:13

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/notify-parent.yml:
- Around line 30-50: The current writes like echo "repo=$PAYLOAD_REPO" >>
$GITHUB_OUTPUT (and the similar echo lines for PAYLOAD_REPO_NAME, PAYLOAD_SHA,
PAYLOAD_SHORT_SHA, PAYLOAD_MESSAGE, PAYLOAD_TYPE, PAYLOAD_ACTOR and the later
git log message) are vulnerable to newline injection because PAYLOAD_* values
can contain newlines; replace each echo-based write to $GITHUB_OUTPUT with
GitHub's safe multiline output pattern: use the heredoc/delimiter style that
appends to the quoted "$GITHUB_OUTPUT" with a unique delimiter per key and place
the untrusted value between the delimiters (i.e., emit the key header then the
delimiter block containing the raw value, then the closing delimiter) so
multiline payloads are preserved and cannot inject additional output lines.
Ensure every occurrence where you currently echo into $GITHUB_OUTPUT (including
the git log/commit message write) is converted to this safe delimiter/heredoc
approach.

Comment thread .github/workflows/notify-parent.yml Outdated
@mateodelnorte
mateodelnorte force-pushed the fix/notify-parent-regex branch from 7561bbe to ea8ea6d Compare February 19, 2026 00:27

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.github/workflows/notify-parent.yml:
- Around line 43-67: The write_output function currently uses a fixed heredoc
delimiter "__EOF__", which can be injected by untrusted values; change
write_output to generate a unique delimiter per call (e.g., random hex/uuid or
mktemp-based token) and use that token in the two delimiter printf lines instead
of "__EOF__", ensuring you write to "$GITHUB_OUTPUT" the same dynamically
generated delimiter for both the opening and closing heredoc; also guard by
regenerating the token if it appears in the value (or choose a sufficiently
random/long token) so the delimiter never collides with the key/value content.

Bash interprets `(` in `[:(]` character classes as an unmatched
subshell opener, causing "unexpected EOF while looking for matching ')'"
(exit code 2). Storing the regex in a variable avoids this because bash
passes variable content directly to the regex engine without shell parsing.

Resolves [[incidents/notify-parent-broken]]
Implements [[tasks/meta-64]]

Co-authored-by: Claude <claude@anthropic.com>
@mateodelnorte
mateodelnorte force-pushed the fix/notify-parent-regex branch from ea8ea6d to ebc0112 Compare February 19, 2026 03:23
@mateodelnorte
mateodelnorte merged commit 79af53a into main Feb 19, 2026
7 checks passed
@mateodelnorte
mateodelnorte deleted the fix/notify-parent-regex branch February 19, 2026 04:03
mateodelnorte added a commit that referenced this pull request Mar 26, 2026
#8)

Bash interprets `(` in `[:(]` character classes as an unmatched
subshell opener, causing "unexpected EOF while looking for matching ')'"
(exit code 2). Storing the regex in a variable avoids this because bash
passes variable content directly to the regex engine without shell parsing.

Resolves [[incidents/notify-parent-broken]]
Implements [[tasks/meta-64]]

Co-authored-by: Claude <claude@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant