← Back to PRs

#20014: fix(nodes): use formatExecCommand for approval request command text

by openperf open 2026-02-18 11:54 View on GitHub →
cli agents size: XS
## Summary This PR fixes a bug where `nodes.run` would consistently fail with an `approval id does not match request` error when the command contained arguments with spaces. The root cause was a command string mismatch between the approval request creation and the gateway-side validation. - The gateway normalizes the command text using `formatExecCommand` to handle shell quoting correctly. - However, the `nodes.run` tool and `nodes invoke` CLI were creating the approval request command text using a simple `command.join(" ")`, which does not preserve quoting for arguments with spaces (e.g., `bash -lc "echo ..."`). This change updates both `nodes-tool.ts` and `register.invoke.ts` to use the canonical `formatExecCommand` helper, ensuring that the command text is consistent across both the request creation and validation paths. This resolves the approval ID correlation failure. ## Test Plan The `formatExecCommand` helper is already covered by unit tests in `system-run-command.test.ts`. For commands without spaces, `formatExecCommand` produces identical output to `join(" ")`, so there is no regression risk for the common case. The fix aligns the approval request creation path with the existing gateway validation path (`getCmdText` in `node-invoke-system-run-approval.ts`), which already uses `formatExecCommand`. Fixes #19862 <!-- greptile_comment --> <h3>Greptile Summary</h3> Fixes a bug where `nodes.run` failed with `approval id does not match request` when the command contained arguments with spaces. The root cause was that the approval request was created using `command.join(" ")`, which loses quoting information, while the gateway-side validation uses `formatExecCommand()` which correctly quotes arguments containing spaces. The fix updates both `nodes-tool.ts` (agent tool path) and `register.invoke.ts` (CLI path) to use `formatExecCommand()`, ensuring the command text is consistent between approval request creation and gateway validation. - Both callsites now use the canonical `formatExecCommand` helper from `system-run-command.ts` - The fix is minimal, targeted, and consistent with how the gateway normalizes command text in `getCmdText()` (`node-invoke-system-run-approval.ts:47-59`) - No remaining `command.join(" ")` patterns for approval command text were found in the codebase - Existing tests in `system-run-command.test.ts` cover the behavior of `formatExecCommand` <h3>Confidence Score: 5/5</h3> - This PR is safe to merge — it's a minimal, well-scoped bug fix with no behavioral side effects for commands without spaces. - The change is two one-line fixes that align the approval request creation with the existing gateway validation logic. The `formatExecCommand` function is well-tested and already used by the gateway. For commands without spaces, `formatExecCommand` produces the same output as `join(" ")`, so there are no regressions for the common case. - No files require special attention. <sub>Last reviewed commit: ed334fb</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs