fix: hide context exception details (#111)
CI / lint (pull_request) Successful in 10s
CI / build-frontend (pull_request) Successful in 4s

This commit is contained in:
timmy committed 2026-08-06 14:17:30 +00:00
1 parent 7f236c5a79
commit f2540fb1db
2 files changed
+38 -8

No files matched your search

+21
View File
@@ -34,6 +34,27 @@ async def test_context_returns_fallback_when_gitea_exceeds_deadline(monkeypatch)
assert cancelled.is_set()
@pytest.mark.anyio
async def test_context_hides_upstream_exception_details(monkeypatch):
async def failing_user():
raise RuntimeError("connection refused by secret.internal.example")
async def empty_collection():
return []
monkeypatch.setattr(main, "current_user", failing_user)
monkeypatch.setattr(main, "repos", empty_collection)
monkeypatch.setattr(main, "issues", empty_collection)
monkeypatch.setattr(main, "pull_requests", empty_collection)
response = await main.context()
body = bytes(response.body)
context = json.loads(body)
assert context["error"] == "Gitea context is temporarily unavailable"
assert b"secret.internal.example" not in body
@pytest.mark.anyio
async def test_context_normalizes_nullable_issue_collections(monkeypatch):
async def user():