Skip to content

Commit f7fc13c

Browse files
authored
fix: treat HTTP 202 Accepted as valid response (#75)
## Summary - Fix `server action rename` incorrectly treating HTTP 202 response as an error - Add HTTP 202 to list of acceptable "no content" status codes alongside 204 - Add test case for HTTP 202 Accepted response handling
1 parent 4cb1d19 commit f7fc13c

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/binarylane/console/runners/command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ def response(self, status_code: int, received: Any) -> None:
108108
if status_code == 401:
109109
self.error(ExitCode.TOKEN, 'Unable to authenticate with API - please run "bl configure" to get started.')
110110

111-
# If no response is available, report an API error (unless it is `204 No Content`)
111+
# If no response is available, report an API error (unless it is `202 Accepted` or `204 No Content`)
112112
if received is None:
113-
if status_code != 204:
113+
if status_code not in (202, 204):
114114
self.error(ExitCode.API, f"HTTP {status_code}")
115115
return
116116

tests/runners/test_command_runner.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ def test_response_handles_nocontent(capsys: CaptureFixture[str]) -> None:
100100
assert captured.err == "" and captured.out == ""
101101

102102

103+
def test_response_handles_accepted(capsys: CaptureFixture[str]) -> None:
104+
"""HTTP 202 Accepted with no body should not be treated as an error."""
105+
runner = TypeRunner(CommandRunner)
106+
107+
runner.test.response(202, None)
108+
109+
captured = capsys.readouterr()
110+
assert captured.err == "" and captured.out == ""
111+
112+
103113
def test_response_handles_ok(capsys: CaptureFixture[str]) -> None:
104114
runner = TypeRunner(CommandRunner)
105115

0 commit comments

Comments
 (0)