Skip to content

The agent that grows with you

fix(buzz): pass edit content literally to the CLI

Reinhold9223a424d8a0
diff --git a/plugins/platforms/buzz/adapter.py b/plugins/platforms/buzz/adapter.py
index 386810b86be..fb7004f1ff6 100644
--- a/plugins/platforms/buzz/adapter.py
+++ b/plugins/platforms/buzz/adapter.py
@@ -864,7 +864,9 @@ class BuzzAdapter(BasePlatformAdapter):
return SendResult(success=False, error="Buzz edit needs a message id")
if not content:
return SendResult(success=False, error="Empty message")
- args = ["messages", "edit", "--event", str(message_id), "--content", content]
+ # Unlike ``messages send``, the CLI's ``messages edit`` takes ``--content`` literally (no ``-``/stdin
+ # expansion); the ``=`` form keeps clap from reading hyphen-leading text as a flag.
+ args = ["messages", "edit", "--event", str(message_id), f"--content={content}"]
code, out, err = await self._run_cli(args)
if code != 0:
return SendResult(success=False, error=_cli_error_message(err, code), retryable=code == 2)
diff --git a/tests/gateway/test_buzz_adapter.py b/tests/gateway/test_buzz_adapter.py
index 9d1455cbf36..1e56af851fa 100644
--- a/tests/gateway/test_buzz_adapter.py
+++ b/tests/gateway/test_buzz_adapter.py
@@ -3513,21 +3513,23 @@ class TestStandaloneSend:
class TestBuzzAdapterEdit:
@pytest.mark.asyncio
- async def test_edit_targets_the_original_event_and_passes_replacement_text(self):
+ @pytest.mark.parametrize("content", ["partial answer\nGrüezi 🌍\n", "--status\n- checking progress"])
+ async def test_edit_preserves_literal_content_and_original_target(self, content):
adapter = _make_adapter()
adapter._channel_state[CHANNEL] = {"chat_type": "group", "last_ts": 0, "seen": {}}
cli = _ScriptedCli()
cli.script("messages", "edit", {"accepted": True, "event_id": "edit1", "message": ""})
adapter._run_cli = cli
- result = await adapter.edit_message(CHANNEL, "orig1", "partial answer")
+ result = await adapter.edit_message(CHANNEL, "orig1", content)
assert result.success is True
+ assert result.message_id == "orig1"
args, stdin_text = cli.calls[0]
assert args[:2] == ["messages", "edit"]
- assert args[args.index("--event") + 1] == "orig1"
- # Unlike ``messages send``, ``messages edit`` treats ``-`` literally.
- assert args[args.index("--content") + 1] == "partial answer"
+ # Unlike ``messages send``, ``messages edit`` takes ``--content`` literally (no stdin); the ``=``
+ # form keeps hyphen-leading replacement text from being parsed as a flag.
+ assert args[2:] == ["--event", "orig1", f"--content={content}"]
assert stdin_text is None
@pytest.mark.asyncio