Handle string data in Originate_Application#66
Conversation
9e840cf to
ca3570c
Compare
Review panel findings — 5 reviewersScope: `b4014a8...HEAD` | base `master` The primary fix (treating a plain string `data` as one argument) is correct and the tests for it are solid. Two issues need a code change before merge. Critical`ami.py:1069` — `Action` header bypasses CRLF validation `validate_header` is defined and called on every header assembled in the loop, plus `ActionID`. But the first item is constructed before the loop: ```python This line does not go through `validate_header`. A `_Request` constructed with a CRLF-bearing action name emits an injected header on the wire with no error raised. Fix: ```python Add a regression test: `_Request("Ping\r\nInjected: x")` should raise `ValueError`. Warning`core.py:844` — `bytes` data produces silent wire corruption `isinstance(data, str)` is `False` for `bytes`, so a `bytes` argument falls through to the join path. Iterating `bytes` yields integers (e.g., `b"goodbye"` → 103, 111, 111...), and `str(d)` on each produces `"103,111,111,100,98,121,101"` in the `Data` header. No exception is raised; Asterisk receives corrupted data. Fix: ```python `ami.py` / `send_action` — `ValueError` is undocumented on the public API `build_request` now raises `ValueError` on CRLF in any header, but neither `build_request` nor `send_action` documents this. Callers that catch only `ManagerError`/`ManagerSocketError` will see unhandled `ValueError` propagate to an outer frame with no warning. Add a raises note to both docstrings: Raises `ValueError` if any header key or value contains CR or LF. Info
5-agent panel: Codex (architecture), internal-consistency, convention/style, silent-failure-hunter (security), test-coverage. |
|
Addressed the review panel findings in
Validation run:
|
Review panel — round 2All round-1 critical and warning findings are correctly resolved. Codex ran live runtime checks and confirmed no new bugs were introduced. One new warning
Fix: if isinstance(data, (bytes, bytearray, memoryview)):
raise TypeError("data must be a string or sequence of strings, not bytes")Info (no code change required)
What the panel agrees is clean
One code fix needed before merge — extend the 5-agent panel: Codex (architecture + runtime checks), internal-consistency, convention/style, silent-failure-hunter (security), test-coverage. |
|
Addressed the round-2 review warning in
Validation run:
|
Review panel — round 3 (commit
|
|
Addressed the round-3 review feedback in
Validation run:
|
Review panel — round 4 (commits
|
|
Addressed the round-4 review feedback in
Validation run:
|
Review panel — satisfiedFive rounds across all commits. No open critical or warning findings remain. The implementation is correct, the tests are thorough, and the guards are well-documented. This PR is ready to merge. |
Summary
datavalue forOriginate_Applicationas one application argument.Root Cause
Originate_Applicationjoined every item indata. A string is iterable, so"goodbye"becameg,o,o,d,b,y,e.Validation
rtk .venv/bin/pytest tests/test_ami_request.py -qrtk .venv/bin/pytest -qrtk .venv/bin/ruff check .rtk .venv/bin/ruff format --check .Closes #11.