fix(webhook): label re-read must hit /api/v1, not the bare host

GITEA_API is the host with no version prefix — ai_review._get / _post append
/api/v1 per call. The re-read helper didn't, so it 404'd on every review and
silently fell back to the payload's verdict: "could not re-read labels for
gitea_admin/pragent#10: HTTP Error 404" in the pod log, usage block still
missing. Caught by labelling PR #10 AI-REVIEW then AI-USAGE, which is the
exact sequence the fix exists to handle.

Test asserts the composed URL, since a wrong path here fails silently by
design (the helper swallows errors so a review is never lost over a usage
section).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B11e8TZZxJyzHW7jj7KWUN
This commit is contained in:
Marcos
2026-08-20 23:29:03 +00:00
parent 4ef62f28bb
commit aedea973ab
2 changed files with 24 additions and 1 deletions
+3 -1
View File
@@ -186,7 +186,9 @@ def _fetch_current_labels(repo: str, index: str) -> list:
opt-in is lost — the review posts without its usage block. Reading the
labels again at review start closes that window.
"""
url = f"{GITEA_API}/repos/{repo}/issues/{index}/labels"
# GITEA_API is the bare host (no /api/v1) — every caller appends the
# version prefix itself; see ai_review._get / _post.
url = f"{GITEA_API}/api/v1/repos/{repo}/issues/{index}/labels"
req = urllib.request.Request(url, headers={
"Authorization": f"token {BOT_TOKEN}",
"Accept": "application/json",