Merge pull request 'fix: Normalize nullable repository descriptions' (#55)
All checks were successful
CI / lint (push) Successful in 7s
Release / release-candidate (push) Successful in 3s
CI / build-frontend (push) Successful in 4s

Closes #54
This commit is contained in:
rockachopa 2026-08-06 00:18:39 +00:00
commit 6678358e4c
2 changed files with 30 additions and 2 deletions

View File

@ -84,7 +84,7 @@ async def context() -> JSONResponse:
} if isinstance(e, TimeoutError) else None)
user_model = User(id=user_data["id"], login=user_data["login"], full_name=user_data.get("full_name", ""), email=user_data.get("email", ""))
repo_models = [
Repo(id=r["id"], name=r["name"], full_name=r["full_name"], description=r.get("description", ""), url=r["html_url"], updated_at=r.get("updated_at", ""))
Repo(id=r["id"], name=r["name"], full_name=r["full_name"], description=r.get("description") or "", url=r["html_url"], updated_at=r.get("updated_at", ""))
for r in repo_data[:50]
if isinstance(r, dict)
]

View File

@ -62,4 +62,32 @@ async def test_context_normalizes_nullable_issue_collections(monkeypatch):
issue = json.loads(response.body)["issues"][0]
assert issue["labels"] == []
assert issue["assignees"] == []
assert issue["assignees"] == []
@pytest.mark.anyio
async def test_context_normalizes_nullable_repository_description(monkeypatch):
async def user():
return {"id": 1, "login": "timmy"}
async def empty_collection():
return []
async def repo_collection():
return [{
"id": 54,
"name": "dashboard",
"full_name": "stackchain/dashboard",
"description": None,
"html_url": "https://forge.example/stackchain/dashboard",
}]
monkeypatch.setattr(main, "current_user", user)
monkeypatch.setattr(main, "repos", repo_collection)
monkeypatch.setattr(main, "issues", empty_collection)
monkeypatch.setattr(main, "pull_requests", empty_collection)
response = await main.context()
repository = json.loads(response.body)["repos"][0]
assert repository["description"] == ""