Skip to content

GH#3605: fix critical quality-debt from PR #796 review — unsafe echo -e in supervisor log functions#4369

Merged
alex-solovyev merged 1 commit intomainfrom
bugfix/gh3605-logging-quote-return
Mar 13, 2026
Merged

GH#3605: fix critical quality-debt from PR #796 review — unsafe echo -e in supervisor log functions#4369
alex-solovyev merged 1 commit intomainfrom
bugfix/gh3605-logging-quote-return

Conversation

@alex-solovyev
Copy link
Copy Markdown
Collaborator

Summary

Fixes the two issues flagged by the Gemini code review on PR #796:

  1. Unsafe argument handling (echo -e with $*): echo -e interprets backslash sequences in the message string. If a log message contains \n, \t, or other escape sequences, they would be silently transformed, corrupting log output. Switching to printf "%b %s\n" passes the caller's message as a %s argument — backslash sequences in $* are never interpreted.

  2. Explicit return 0 statements: Already present in the multi-line form in _common.sh (added during the supervisor modularisation in t1031: Modularize supervisor-helper.sh into domain modules #1359). This commit preserves them and adds a block comment documenting the printf rationale.

Changes

  • .agents/scripts/supervisor-archived/_common.sh: Replace echo -e "... $*" with printf "%b %s\n" "..." "$*" in all five logging functions (log_info, log_success, log_warn, log_error, log_verbose). Preserve existing return 0 statements.

Verification

  • ShellCheck passes (only SC1091 info for sourced file, expected)
  • Manual test confirms: backslash sequences in messages are printed literally, not interpreted; ANSI color codes in the format string still render correctly; log_verbose only outputs when SUPERVISOR_VERBOSE=true; all functions return 0

Closes #3605

PR #796 redirected log_info/success/warn/error/verbose to stderr, but the
Gemini review flagged two remaining issues:

1. Unsafe argument handling: echo -e with $* can interpret backslash
   sequences in log messages (e.g. \n, \t) as escape codes, corrupting
   output. Switching to printf "%b %s\n" passes the message as a separate
   "%s" argument, preventing interpretation of backslash sequences in
   caller-supplied strings.

2. Explicit return 0 statements are already present in the multi-line form
   in _common.sh (added during the supervisor modularisation). This commit
   preserves them and documents the printf rationale in the block comment.

Closes #3605
@github-actions github-actions bot added the bug Auto-created from TODO.md tag label Mar 13, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 13, 2026

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Review skipped — only excluded labels are configured. (1)
  • no-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a2163f88-618f-40ec-8260-55ee72b56580

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/gh3605-logging-quote-return
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

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

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 resolves a critical quality debt by refactoring the supervisor's logging functions to use printf instead of echo -e. This change significantly improves the safety and reliability of log output by preventing the unintended interpretation of backslash sequences in log messages, thus ensuring accurate and uncorrupted logging. The update also includes documentation for the printf rationale and preserves existing explicit return statements.

Highlights

  • Unsafe argument handling: Replaced echo -e with printf "%b %s\n" in supervisor log functions to prevent unintended interpretation of backslash sequences in log messages, enhancing log output reliability.
  • Explicit return statements: Preserved existing return 0 statements in logging functions and added a block comment documenting the printf rationale for clarity and maintainability.
Changelog
  • .agents/scripts/supervisor-archived/_common.sh
    • Replaced echo -e "... $*" with printf "%b %s\n" "..." "$*" in log_info, log_success, log_warn, log_error, and log_verbose functions.
    • Added a block comment explaining the rationale for using printf to safely handle arbitrary message content.
Activity
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 413 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Fri Mar 13 07:20:20 UTC 2026: Code review monitoring started
Fri Mar 13 07:20:20 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 413

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 413
  • VULNERABILITIES: 0

Generated on: Fri Mar 13 07:20:24 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses a critical security issue by replacing the unsafe echo -e with printf for logging. This prevents potential log corruption or unexpected behavior from special characters in log messages. My review includes suggestions to further improve the robustness of these logging functions by ensuring they don't cause a script to exit on a logging failure, and to improve consistency across all the logging functions.

Comment on lines +36 to 37
printf "%b %s\n" "${BLUE}[SUPERVISOR]${NC}" "$*" >&2
return 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For improved robustness, consider adding || true to the printf command. This prevents the script from exiting on a logging failure (e.g., a broken pipe on stderr) when set -e is active. This change also makes the explicit return 0 redundant, as the command will always succeed.

Suggested change
printf "%b %s\n" "${BLUE}[SUPERVISOR]${NC}" "$*" >&2
return 0
printf "%b %s\n" "${BLUE}[SUPERVISOR]${NC}" "$*" >&2 || true
References
  1. When set -e is active, using || true for non-critical commands like logging prevents the script from exiting prematurely on minor failures (e.g., broken pipe), ensuring robustness.

Comment on lines +41 to 42
printf "%b %s\n" "${GREEN}[SUPERVISOR]${NC}" "$*" >&2
return 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For consistency and robustness, consider adding || true here as well. This prevents script termination on logging failures and makes the return 0 redundant.

Suggested change
printf "%b %s\n" "${GREEN}[SUPERVISOR]${NC}" "$*" >&2
return 0
printf "%b %s\n" "${GREEN}[SUPERVISOR]${NC}" "$*" >&2 || true
References
  1. When set -e is active, using || true for non-critical commands like logging prevents the script from exiting prematurely on minor failures (e.g., broken pipe), ensuring robustness.

Comment on lines +46 to 47
printf "%b %s\n" "${YELLOW}[SUPERVISOR]${NC}" "$*" >&2
return 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For consistency and robustness, consider adding || true here as well. This prevents script termination on logging failures and makes the return 0 redundant.

Suggested change
printf "%b %s\n" "${YELLOW}[SUPERVISOR]${NC}" "$*" >&2
return 0
printf "%b %s\n" "${YELLOW}[SUPERVISOR]${NC}" "$*" >&2 || true
References
  1. When set -e is active, using || true for non-critical commands like logging prevents the script from exiting prematurely on minor failures (e.g., broken pipe), ensuring robustness.

Comment on lines +51 to 52
printf "%b %s\n" "${RED}[SUPERVISOR]${NC}" "$*" >&2
return 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For consistency and robustness, consider adding || true here as well. This prevents script termination on logging failures and makes the return 0 redundant.

Suggested change
printf "%b %s\n" "${RED}[SUPERVISOR]${NC}" "$*" >&2
return 0
printf "%b %s\n" "${RED}[SUPERVISOR]${NC}" "$*" >&2 || true
References
  1. When set -e is active, using || true for non-critical commands like logging prevents the script from exiting prematurely on minor failures (e.g., broken pipe), ensuring robustness.

@alex-solovyev alex-solovyev merged commit c001ee1 into main Mar 13, 2026
28 checks passed
@alex-solovyev alex-solovyev deleted the bugfix/gh3605-logging-quote-return branch March 13, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

quality-debt: PR #796 review feedback (critical)

1 participant