fix: blocked-by parser matches backtick-quoted code in task descriptions#2232
fix: blocked-by parser matches backtick-quoted code in task descriptions#2232marcusquinn merged 1 commit intomainfrom
Conversation
The regex 'blocked-by:[^ ]+' matches any non-space chars after 'blocked-by:', including backticks from inline code like `blocked-by:` in descriptions. This caused t1311 and t1314 to be falsely blocked by dependency '`'. Fix: require value to start with task ID pattern (t followed by digits). Applied to all 5 files with the vulnerable pattern: - cron.sh is_task_blocked() - ai-actions.sh - todo-sync.sh auto_unblock_resolved_tasks() - sanity-check.sh - ai-context.sh issue-audit.sh already used stricter [A-Za-z0-9.,]+ — unaffected.
Summary of ChangesHello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where the Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
WalkthroughFive shell scripts in the supervisor automation suite were updated to standardize blocker field extraction patterns. The regex patterns for Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Tue Feb 24 20:45:17 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a bug where the blocked-by parser was too broad and could incorrectly match backticks in task descriptions. The fix, which makes the regex more specific by requiring the value to start with a task ID pattern (t[0-9]), has been consistently applied across all five affected files.
My review includes suggestions to further improve the robustness of this regex by restricting allowed characters to only those valid in a task ID list (digits, dots, and commas). Additionally, in some instances, I've suggested using tail -1 instead of head -1 for more robust metadata extraction, aligning with repository guidelines. Overall, this is a good fix that improves the reliability of task dependency parsing.
| started=$(printf '%s' "$task_line" | grep -oE 'started:[^ ]+' || echo "") | ||
| local blocked | ||
| blocked=$(printf '%s' "$task_line" | grep -oE 'blocked-by:[^ ]+' || echo "") | ||
| blocked=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9][^ ]*' || echo "") |
There was a problem hiding this comment.
While the new regex t[0-9][^ ]* correctly fixes the issue with backticks, it's still a bit permissive as [^ ]* can match any non-space characters. To make the pattern more robust and specific to the task ID format (which consists of t, digits, dots, and commas for lists), I suggest using t[0-9.,]+. This will prevent matching invalid characters that might appear adjacent to the blocked-by: field.
| blocked=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9][^ ]*' || echo "") | |
| blocked=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9.,]+' || echo "") |
| continue | ||
| fi | ||
| blocker=$(echo "$line" | grep -oE 'blocked-by:[^ ]+' | head -1) | ||
| blocker=$(echo "$line" | grep -oE 'blocked-by:t[0-9][^ ]*' | head -1) |
There was a problem hiding this comment.
While the new regex t[0-9][^ ]* correctly fixes the issue with backticks, it's still a bit permissive as [^ ]* can match any non-space characters. To make the pattern more robust and specific to the task ID format (which consists of t, digits, dots, and commas for lists), I suggest using t[0-9.,]+. This will prevent matching invalid characters that might appear adjacent to the blocked-by: field. Additionally, for robustness when extracting metadata fields, tail -1 should be used instead of head -1.
| blocker=$(echo "$line" | grep -oE 'blocked-by:t[0-9][^ ]*' | head -1) | |
| blocker=$(echo "$line" | grep -oE 'blocked-by:t[0-9.,]+' | tail -1) |
References
- When extracting metadata fields from a line using 'grep' and 'sed' in shell scripts, use 'tail -1' instead of 'head -1' to ensure robustness, especially when the field might appear multiple times or be at the end of the line.
| # to avoid matching backtick-quoted mentions like `blocked-by:` in descriptions | ||
| local blocked_by | ||
| blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:[^ ]+' | sed 's/blocked-by://' || true) | ||
| blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9][^ ]*' | sed 's/blocked-by://' || true) |
There was a problem hiding this comment.
While the new regex t[0-9][^ ]* correctly fixes the issue with backticks, it's still a bit permissive as [^ ]* can match any non-space characters. To make the pattern more robust and specific to the task ID format (which consists of t, digits, dots, and commas for lists), I suggest using t[0-9.,]+. This will prevent matching invalid characters that might appear adjacent to the blocked-by: field.
| blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9][^ ]*' | sed 's/blocked-by://' || true) | |
| blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9.,]+' | sed 's/blocked-by://' || true) |
| current_line=$(sed -n "${line_num}p" "$todo_file") | ||
| local blocked_by | ||
| blocked_by=$(printf '%s' "$current_line" | grep -oE 'blocked-by:[^ ]+' | head -1 | sed 's/blocked-by://' || echo "") | ||
| blocked_by=$(printf '%s' "$current_line" | grep -oE 'blocked-by:t[0-9][^ ]*' | head -1 | sed 's/blocked-by://' || echo "") |
There was a problem hiding this comment.
While the new regex t[0-9][^ ]* correctly fixes the issue with backticks, it's still a bit permissive as [^ ]* can match any non-space characters. To make the pattern more robust and specific to the task ID format (which consists of t, digits, dots, and commas for lists), I suggest using t[0-9.,]+. This will prevent matching invalid characters that might appear adjacent to the blocked-by: field. Additionally, for robustness when extracting metadata fields, tail -1 should be used instead of head -1.
| blocked_by=$(printf '%s' "$current_line" | grep -oE 'blocked-by:t[0-9][^ ]*' | head -1 | sed 's/blocked-by://' || echo "") | |
| blocked_by=$(printf '%s' "$current_line" | grep -oE 'blocked-by:t[0-9.,]+' | tail -1 | sed 's/blocked-by://' || echo "") |
References
- When extracting metadata fields from a line using 'grep' and 'sed' in shell scripts, use 'tail -1' instead of 'head -1' to ensure robustness, especially when the field might appear multiple times or be at the end of the line.
| # Extract blocked-by dependencies | ||
| local blocked_by="" | ||
| blocked_by=$(printf '%s' "$line" | grep -oE 'blocked-by:[^ ]+' | head -1 | sed 's/blocked-by://' || echo "") | ||
| blocked_by=$(printf '%s' "$line" | grep -oE 'blocked-by:t[0-9][^ ]*' | head -1 | sed 's/blocked-by://' || echo "") |
There was a problem hiding this comment.
While the new regex t[0-9][^ ]* correctly fixes the issue with backticks, it's still a bit permissive as [^ ]* can match any non-space characters. To make the pattern more robust and specific to the task ID format (which consists of t, digits, dots, and commas for lists), I suggest using t[0-9.,]+. This will prevent matching invalid characters that might appear adjacent to the blocked-by: field. Additionally, for robustness when extracting metadata fields, tail -1 should be used instead of head -1.
| blocked_by=$(printf '%s' "$line" | grep -oE 'blocked-by:t[0-9][^ ]*' | head -1 | sed 's/blocked-by://' || echo "") | |
| blocked_by=$(printf '%s' "$line" | grep -oE 'blocked-by:t[0-9.,]+' | tail -1 | sed 's/blocked-by://' || echo "") |
References
- When extracting metadata fields from a line using 'grep' and 'sed' in shell scripts, use 'tail -1' instead of 'head -1' to ensure robustness, especially when the field might appear multiple times or be at the end of the line.
There was a problem hiding this comment.
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 @.agents/scripts/supervisor/cron.sh:
- Around line 392-395: The current extraction for blocked_by can match
backtick-quoted inline code and trailing punctuation; update the grep/sed
pattern used to populate blocked_by (the variable derived from task_line) to
require a start-or-whitespace boundary before "blocked-by:" (e.g.
(^|[[:space:]])blocked-by:) and to only capture one or more comma-separated task
IDs that strictly match t[0-9]+ with a clear end boundary (comma, whitespace or
end-of-string) so punctuation/backticks are excluded; apply the identical
tightened regex logic to the other scripts you modified to keep parsing
consistent.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.agents/scripts/supervisor/ai-actions.sh.agents/scripts/supervisor/ai-context.sh.agents/scripts/supervisor/cron.sh.agents/scripts/supervisor/sanity-check.sh.agents/scripts/supervisor/todo-sync.sh
| # Extract blocked-by: field — require value to start with a task ID (tNNN) | ||
| # to avoid matching backtick-quoted mentions like `blocked-by:` in descriptions | ||
| local blocked_by | ||
| blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:[^ ]+' | sed 's/blocked-by://' || true) | ||
| blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9][^ ]*' | sed 's/blocked-by://' || true) |
There was a problem hiding this comment.
Harden blocked‑by parsing to ignore backtick‑quoted inline code
Line 395 can still match blocked-by:t123 inside inline code because the pattern doesn’t require a whitespace/start boundary and allows trailing punctuation. That can reintroduce false blockers. Consider anchoring on whitespace/start and limiting to comma‑separated task IDs; apply the same pattern across the other updated scripts for consistency.
🔧 Suggested regex tightening
- blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9][^ ]*' | sed 's/blocked-by://' || true)
+ blocked_by=$(printf '%s' "$task_line" |
+ grep -oE '(^|[[:space:]])blocked-by:t[0-9]+(\.[0-9]+)*(,[[:space:]]*t[0-9]+(\.[0-9]+)*)*' |
+ sed -E 's/^[[:space:]]*blocked-by://' || true)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Extract blocked-by: field — require value to start with a task ID (tNNN) | |
| # to avoid matching backtick-quoted mentions like `blocked-by:` in descriptions | |
| local blocked_by | |
| blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:[^ ]+' | sed 's/blocked-by://' || true) | |
| blocked_by=$(printf '%s' "$task_line" | grep -oE 'blocked-by:t[0-9][^ ]*' | sed 's/blocked-by://' || true) | |
| # Extract blocked-by: field — require value to start with a task ID (tNNN) | |
| # to avoid matching backtick-quoted mentions like `blocked-by:` in descriptions | |
| local blocked_by | |
| blocked_by=$(printf '%s' "$task_line" | | |
| grep -oE '(^|[[:space:]])blocked-by:t[0-9]+(\.[0-9]+)*(,[[:space:]]*t[0-9]+(\.[0-9]+)*)*' | | |
| sed -E 's/^[[:space:]]*blocked-by://' || true) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.agents/scripts/supervisor/cron.sh around lines 392 - 395, The current
extraction for blocked_by can match backtick-quoted inline code and trailing
punctuation; update the grep/sed pattern used to populate blocked_by (the
variable derived from task_line) to require a start-or-whitespace boundary
before "blocked-by:" (e.g. (^|[[:space:]])blocked-by:) and to only capture one
or more comma-separated task IDs that strictly match t[0-9]+ with a clear end
boundary (comma, whitespace or end-of-string) so punctuation/backticks are
excluded; apply the identical tightened regex logic to the other scripts you
modified to keep parsing consistent.



Summary
blocked-by:[^ ]+regex matches backticks from inline code in descriptions`blocked-by:t[0-9]Impact
Summary by CodeRabbit