Skip to content

Commit

Permalink
fix(bitrisescript): only log Bitrise response content on error
Browse files Browse the repository at this point in the history
This is actually very verbose and makes the Taskcluster logs very
difficult to read, so only log it on error.
  • Loading branch information
ahal committed Mar 26, 2024
1 parent f67336f commit 429c88a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions bitrisescript/src/bitrisescript/bitrise.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ async def request(self, endpoint: str, method: str = "get", **kwargs: Any) -> An
while True:
r = await self._client.request(method, url, **kwargs)
log.debug(f"{method_and_url} returned HTTP code {r.status}")
if r.status >= 400:
log.debug(f"{method_and_url} returned JSON:\n{pformat(data)}")
r.raise_for_status()

response = await r.json()

if "data" not in response:
Expand All @@ -104,8 +108,6 @@ async def request(self, endpoint: str, method: str = "get", **kwargs: Any) -> An
break
kwargs.setdefault("params", {})["next"] = next

log.debug(f"{method_and_url} returned JSON {pformat(data)}")

return data


Expand Down
4 changes: 3 additions & 1 deletion bitrisescript/tests/test_bitrise.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ async def test_bitrise_client_request(config, mocker, client, prefix, endpoint,
{"Authorization": config["bitrise"]["access_token"]},
)

response = mocker.AsyncMock()
response.status = 200
m = mocker.patch.object(client._client, "request", return_value=Future())
m.return_value.set_result(mocker.AsyncMock())
m.return_value.set_result(response)

if prefix:
client.prefix = prefix
Expand Down

0 comments on commit 429c88a

Please sign in to comment.