Fix Forgejo issue lifecycle identifiers
This commit is contained in:
parent
d58bfd1f96
commit
3523a7decc
3 changed files with 33 additions and 2 deletions
|
|
@ -113,6 +113,21 @@ def _mapping_backend_name(backend_type: str) -> str:
|
|||
return "sqlite" if backend_type == "local" else backend_type
|
||||
|
||||
|
||||
def _public_issue_id(issue: Issue, backend_type: str) -> str:
|
||||
"""Return the identifier accepted by the backend's issue routes.
|
||||
|
||||
Forgejo/Gitea exposes both a database-wide ``id`` and a repository-local
|
||||
issue ``number``. Its issue CRUD routes address the latter, so returning
|
||||
the database ID from ingestion makes the documented POST -> PATCH lifecycle
|
||||
fail with 404. Local backends continue to expose their native string ID.
|
||||
"""
|
||||
if backend_type in {"gitea", "github"} and issue.number:
|
||||
return str(issue.number)
|
||||
if issue.id:
|
||||
return issue.id
|
||||
return str(issue.number)
|
||||
|
||||
|
||||
def _upsert_mapping_if_requested(
|
||||
payload: TaskIngestionRequest,
|
||||
*,
|
||||
|
|
@ -184,7 +199,7 @@ async def ingest_task(payload: TaskIngestionRequest) -> TaskIngestionResponse:
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
issue_id = created.id or str(created.number)
|
||||
issue_id = _public_issue_id(created, backend_type)
|
||||
issue_url: Optional[str] = None
|
||||
if created.sync_metadata:
|
||||
issue_url = created.sync_metadata.get("url") or created.sync_metadata.get("html_url")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue