From 9fb7cbd4fb9b65aaf27b6dff20404896c7c03d6d Mon Sep 17 00:00:00 2001 From: Nathan O'Sullivan Date: Tue, 13 Jan 2026 14:47:36 +1000 Subject: [PATCH] fix: treat HTTP 202 Accepted as valid response with no body The `server action rename` command returns HTTP 202 with no body for async operations. Previously this was incorrectly treated as an error, outputting "ERROR: HTTP 202" with exit status 4. --- src/binarylane/console/runners/command.py | 4 ++-- tests/runners/test_command_runner.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/binarylane/console/runners/command.py b/src/binarylane/console/runners/command.py index c03dad6..78c3b8b 100644 --- a/src/binarylane/console/runners/command.py +++ b/src/binarylane/console/runners/command.py @@ -108,9 +108,9 @@ def response(self, status_code: int, received: Any) -> None: if status_code == 401: self.error(ExitCode.TOKEN, 'Unable to authenticate with API - please run "bl configure" to get started.') - # If no response is available, report an API error (unless it is `204 No Content`) + # If no response is available, report an API error (unless it is `202 Accepted` or `204 No Content`) if received is None: - if status_code != 204: + if status_code not in (202, 204): self.error(ExitCode.API, f"HTTP {status_code}") return diff --git a/tests/runners/test_command_runner.py b/tests/runners/test_command_runner.py index 85bd26e..e6027d0 100644 --- a/tests/runners/test_command_runner.py +++ b/tests/runners/test_command_runner.py @@ -100,6 +100,16 @@ def test_response_handles_nocontent(capsys: CaptureFixture[str]) -> None: assert captured.err == "" and captured.out == "" +def test_response_handles_accepted(capsys: CaptureFixture[str]) -> None: + """HTTP 202 Accepted with no body should not be treated as an error.""" + runner = TypeRunner(CommandRunner) + + runner.test.response(202, None) + + captured = capsys.readouterr() + assert captured.err == "" and captured.out == "" + + def test_response_handles_ok(capsys: CaptureFixture[str]) -> None: runner = TypeRunner(CommandRunner)