Compare commits
2 Commits
5f80fc2531
...
cd309ee290
| Author | SHA1 | Date | |
|---|---|---|---|
| cd309ee290 | |||
| 478aee9bed |
@@ -272,9 +272,9 @@ async def get_issue_tool(gitea: GiteaClient, arguments: dict[str, Any]) -> dict[
|
|||||||
"title": limit_text(str(issue.get("title", ""))),
|
"title": limit_text(str(issue.get("title", ""))),
|
||||||
"body": limit_text(str(issue.get("body", ""))),
|
"body": limit_text(str(issue.get("body", ""))),
|
||||||
"state": issue.get("state", ""),
|
"state": issue.get("state", ""),
|
||||||
"author": issue.get("user", {}).get("login", ""),
|
"author": (issue.get("user") or {}).get("login", ""),
|
||||||
"labels": [label.get("name", "") for label in issue.get("labels", [])],
|
"labels": [label.get("name", "") for label in (issue.get("labels") or [])],
|
||||||
"assignees": [assignee.get("login", "") for assignee in issue.get("assignees", [])],
|
"assignees": [assignee.get("login", "") for assignee in (issue.get("assignees") or [])],
|
||||||
"created_at": issue.get("created_at", ""),
|
"created_at": issue.get("created_at", ""),
|
||||||
"updated_at": issue.get("updated_at", ""),
|
"updated_at": issue.get("updated_at", ""),
|
||||||
"url": issue.get("html_url", ""),
|
"url": issue.get("html_url", ""),
|
||||||
|
|||||||
@@ -265,6 +265,34 @@ async def test_extended_read_tools_failure_mode() -> None:
|
|||||||
await list_commits_tool(ErrorGitea(), {"owner": "acme", "repo": "app"})
|
await list_commits_tool(ErrorGitea(), {"owner": "acme", "repo": "app"})
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_get_issue_tolerates_null_collections() -> None:
|
||||||
|
"""Regression for #13: Gitea may return null for labels/assignees/user.
|
||||||
|
|
||||||
|
`.get(key, [])` returns None when the key is present with a null value, so
|
||||||
|
iterating the result raised `'NoneType' object is not iterable`.
|
||||||
|
"""
|
||||||
|
|
||||||
|
class NullFieldsGitea(StubGitea):
|
||||||
|
async def get_issue(self, owner, repo, index):
|
||||||
|
return {
|
||||||
|
"number": index,
|
||||||
|
"title": "Issue",
|
||||||
|
"body": "Body",
|
||||||
|
"state": "open",
|
||||||
|
"user": None,
|
||||||
|
"labels": None,
|
||||||
|
"assignees": None,
|
||||||
|
}
|
||||||
|
|
||||||
|
result = await get_issue_tool(
|
||||||
|
NullFieldsGitea(), {"owner": "acme", "repo": "app", "issue_number": 1}
|
||||||
|
)
|
||||||
|
assert result["author"] == ""
|
||||||
|
assert result["labels"] == []
|
||||||
|
assert result["assignees"] == []
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"tool,args,expected_key",
|
"tool,args,expected_key",
|
||||||
|
|||||||
Reference in New Issue
Block a user