mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 04:40:38 +08:00
Fix URL encoding in Azure DevOps webhook handler
This commit is contained in:
@ -6,6 +6,8 @@ import json
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import secrets
|
import secrets
|
||||||
|
from urllib.parse import unquote
|
||||||
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from fastapi import APIRouter, Depends, FastAPI, HTTPException
|
from fastapi import APIRouter, Depends, FastAPI, HTTPException
|
||||||
from fastapi.security import HTTPBasic, HTTPBasicCredentials
|
from fastapi.security import HTTPBasic, HTTPBasicCredentials
|
||||||
@ -81,7 +83,7 @@ async def handle_webhook(background_tasks: BackgroundTasks, request: Request):
|
|||||||
actions = []
|
actions = []
|
||||||
if data["eventType"] == "git.pullrequest.created":
|
if data["eventType"] == "git.pullrequest.created":
|
||||||
# API V1 (latest)
|
# API V1 (latest)
|
||||||
pr_url = data["resource"]["_links"]["web"]["href"].replace("_apis/git/repositories", "_git")
|
pr_url = unquote(data["resource"]["_links"]["web"]["href"].replace("_apis/git/repositories", "_git"))
|
||||||
log_context["event"] = data["eventType"]
|
log_context["event"] = data["eventType"]
|
||||||
log_context["api_url"] = pr_url
|
log_context["api_url"] = pr_url
|
||||||
await _perform_commands_azure("pr_commands", PRAgent(), pr_url, log_context)
|
await _perform_commands_azure("pr_commands", PRAgent(), pr_url, log_context)
|
||||||
@ -90,7 +92,7 @@ async def handle_webhook(background_tasks: BackgroundTasks, request: Request):
|
|||||||
if available_commands_rgx.match(data["resource"]["comment"]["content"]):
|
if available_commands_rgx.match(data["resource"]["comment"]["content"]):
|
||||||
if(data["resourceVersion"] == "2.0"):
|
if(data["resourceVersion"] == "2.0"):
|
||||||
repo = data["resource"]["pullRequest"]["repository"]["webUrl"]
|
repo = data["resource"]["pullRequest"]["repository"]["webUrl"]
|
||||||
pr_url = f'{repo}/pullrequest/{data["resource"]["pullRequest"]["pullRequestId"]}'
|
pr_url = unquote(f'{repo}/pullrequest/{data["resource"]["pullRequest"]["pullRequestId"]}')
|
||||||
actions = [data["resource"]["comment"]["content"]]
|
actions = [data["resource"]["comment"]["content"]]
|
||||||
else:
|
else:
|
||||||
# API V1 not supported as it does not contain the PR URL
|
# API V1 not supported as it does not contain the PR URL
|
||||||
|
Reference in New Issue
Block a user