Report receiver: fix a race in its tests, and log Gitea's reasons
shellcheck / shellcheck (push) Failing after 16s
shellcheck / shellcheck (push) Failing after 16s
The first test checked that a report was no longer pending as soon as its log reached the fake Gitea, a moment before the receiver marks it filed, so it could fail; wait for the mark instead. The tests now close their servers and error responses. When Gitea refuses an issue or attachment, the receiver closes the reply and logs Gitea's reason, such as a token without the right permission. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -191,8 +191,14 @@ class Gitea:
|
||||
"Content-Type": content_type,
|
||||
"Accept": "application/json",
|
||||
})
|
||||
with urllib.request.urlopen(request, timeout=self.timeout) as response:
|
||||
return json.load(response)
|
||||
try:
|
||||
with urllib.request.urlopen(request, timeout=self.timeout) as response:
|
||||
return json.load(response)
|
||||
except urllib.error.HTTPError as error:
|
||||
# Gitea's reason, e.g. a token without the right permission, for the journal
|
||||
with error:
|
||||
detail = error.read(500).decode("utf-8", errors="replace").strip()
|
||||
raise OSError(f"Gitea answered {error.code}: {detail or error.reason}") from None
|
||||
|
||||
def create_issue(self, title, body):
|
||||
"""The new issue's number."""
|
||||
|
||||
Reference in New Issue
Block a user