GH#4937: Fix wp-helper.sh SSH stdout capture#4940
Conversation
) The bash -lc '...' _ path args pattern passed as separate SSH arguments broke because SSH concatenates all remote-command arguments with spaces before the remote shell re-parses them. The single quotes were stripped locally, so bash -c only received 'cd' as its command — silently discarding the rest of the pipeline including wp output. Replace with build_remote_wp_cmd() that constructs a single properly- quoted command string using printf %q. SSH sends it intact to the remote shell. No bash -lc wrapper needed — SSH already invokes the user's login shell. Also redirect the run_wp_command INFO line to stderr so callers can capture just the WP-CLI stdout without the [INFO] prefix mixed in.
Summary of ChangesHello, 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 a critical bug in Highlights
Changelog
Activity
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
|
|
Important Review skippedAuto reviews are limited based on label configuration. 🚫 Review skipped — only excluded labels are configured. (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughAdded Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
There was a problem hiding this comment.
Code Review
This pull request effectively resolves a critical bug where remote SSH commands were being truncated due to improper argument quoting. The introduction of the build_remote_wp_cmd function is a robust solution that correctly handles shell escaping. Additionally, redirecting informational logs to stderr is a great improvement for script usability. The changes are well-implemented and clearly documented. I have one minor suggestion to make the new helper function even more concise.
| local escaped_args="" | ||
| local arg | ||
| for arg in "${wp_args[@]}"; do | ||
| escaped_args+=" $(printf '%q' "$arg")" | ||
| done |
There was a problem hiding this comment.
This loop for building escaped_args can be made more concise and efficient. The printf built-in can process an entire array of arguments at once, avoiding the need for a for loop and string concatenation.
| local escaped_args="" | |
| local arg | |
| for arg in "${wp_args[@]}"; do | |
| escaped_args+=" $(printf '%q' "$arg")" | |
| done | |
| local escaped_args | |
| escaped_args=$(printf ' %q' "${wp_args[@]}") |
References
- Use bash arrays for dynamic command construction to avoid duplicating argument expansion patterns and ensure safe handling of arguments, especially when constructing commands from arrays.
…itter Root cause: multiple pulse runners evaluating the same issue simultaneously create duplicate PRs. Process-based dedup (has_worker_for_repo_issue, is-duplicate) only sees local processes — invisible across machines. Fix 1: Add is-assigned command to dispatch-dedup-helper.sh that queries GitHub assignees before dispatch. If another runner already self-assigned, skip the issue. This is the primary cross-machine dedup guard. Fix 2: Add 0-30s random startup jitter to pulse-wrapper.sh so concurrent launchd-triggered pulses don't evaluate issues at the same instant. Configurable via PULSE_JITTER_MAX (set to 0 to disable). Fix 3: Update pulse.md dispatch instructions to enforce the assignee check as a mandatory step alongside existing local process dedup. Observed: PR #4940 duplicated PR #4938 for issue #4937 because alex-solovyev's pulse dispatched 2 min after marcusquinn self-assigned, interpreting the in-progress worker as 'failed'.
…tter (#4948) * fix: prevent duplicate dispatch across runners via assignee check + jitter Root cause: multiple pulse runners evaluating the same issue simultaneously create duplicate PRs. Process-based dedup (has_worker_for_repo_issue, is-duplicate) only sees local processes — invisible across machines. Fix 1: Add is-assigned command to dispatch-dedup-helper.sh that queries GitHub assignees before dispatch. If another runner already self-assigned, skip the issue. This is the primary cross-machine dedup guard. Fix 2: Add 0-30s random startup jitter to pulse-wrapper.sh so concurrent launchd-triggered pulses don't evaluate issues at the same instant. Configurable via PULSE_JITTER_MAX (set to 0 to disable). Fix 3: Update pulse.md dispatch instructions to enforce the assignee check as a mandatory step alongside existing local process dedup. Observed: PR #4940 duplicated PR #4938 for issue #4937 because alex-solovyev's pulse dispatched 2 min after marcusquinn self-assigned, interpreting the in-progress worker as 'failed'. * fix: validate PULSE_JITTER_MAX as numeric, use read -ra for assignee parsing Address Gemini review feedback: - Validate PULSE_JITTER_MAX is numeric before arithmetic (prevents set -e failures from non-integer env var values) - Use read -ra for comma-separated assignee parsing instead of IFS word splitting (more robust against whitespace edge cases)
Summary
bash -lc '...' _ path argspassed as separate SSH arguments broke because SSH concatenates all remote-command arguments with spaces before the remote shell re-parses them. The local single quotes were stripped, sobash -conly receivedcdas its command — silently discarding thewppipeline and its stdout.build_remote_wp_cmd()function constructs a single properly-quoted command string usingprintf %q. SSH sends it intact to the remote shell. Nobash -lcwrapper needed — SSH already invokes the user's login shell.print_infoinrun_wp_command()now goes to stderr (>&2) so callers can capture just the WP-CLI stdout without the[INFO]prefix mixed in.Changes
.agents/scripts/wp-helper.sh: Addbuild_remote_wp_cmd()helper, replace brokenbash -lcSSH pattern in both key-based and password-based paths, redirect INFO line to stderr.Testing
Closes #4937
Summary by CodeRabbit