Fix Cursor cloud validation and dedupe after failed reviews.
Use a no-repo cloud agent since Gitea remotes are not supported for clone, and only mark dedupe complete on success so review_requested can retry. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -28,19 +28,51 @@ export async function runReview(input: {
|
||||
prNumber,
|
||||
headSha
|
||||
});
|
||||
if (input.dedupe.has(dedupeKey)) {
|
||||
const dedupeSlot = input.dedupe.tryAcquire(dedupeKey);
|
||||
if (dedupeSlot !== "acquired") {
|
||||
log("info", "Review skipped: duplicate webhook", {
|
||||
correlation_id: input.correlationId,
|
||||
owner,
|
||||
repo,
|
||||
pr_number: prNumber,
|
||||
head_sha: headSha
|
||||
head_sha: headSha,
|
||||
reason: dedupeSlot
|
||||
});
|
||||
return "skipped";
|
||||
}
|
||||
input.dedupe.mark(dedupeKey);
|
||||
|
||||
const gitea = new GiteaClient(input.env.GITEA_BASE_URL, input.env.GITEA_TOKEN, 30000);
|
||||
try {
|
||||
return await executeReview({
|
||||
input,
|
||||
gitea,
|
||||
owner,
|
||||
repo,
|
||||
prNumber,
|
||||
headSha,
|
||||
dedupeKey
|
||||
});
|
||||
} catch (error) {
|
||||
input.dedupe.release(dedupeKey);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function executeReview(params: {
|
||||
input: {
|
||||
env: Env;
|
||||
event: RoutedEvent;
|
||||
dedupe: DedupeStore;
|
||||
correlationId: string;
|
||||
};
|
||||
gitea: GiteaClient;
|
||||
owner: string;
|
||||
repo: string;
|
||||
prNumber: number;
|
||||
headSha: string;
|
||||
dedupeKey: string;
|
||||
}): Promise<"skipped" | "success"> {
|
||||
const { input, gitea, owner, repo, prNumber, headSha, dedupeKey } = params;
|
||||
const pull = await retry({
|
||||
fn: () => gitea.getPull(owner, repo, prNumber),
|
||||
retries: 2,
|
||||
@@ -69,6 +101,7 @@ export async function runReview(input: {
|
||||
botLogin: input.env.GITEA_BOT_LOGIN
|
||||
});
|
||||
if (!should.process) {
|
||||
input.dedupe.release(dedupeKey);
|
||||
log("info", "Review skipped by policy", {
|
||||
correlation_id: input.correlationId,
|
||||
owner,
|
||||
@@ -103,10 +136,6 @@ export async function runReview(input: {
|
||||
prompt,
|
||||
timeoutMs: input.env.REVIEW_TIMEOUT_MS,
|
||||
model: repoConfig.model,
|
||||
giteaBaseUrl: input.env.GITEA_BASE_URL,
|
||||
owner,
|
||||
repo,
|
||||
headRef: pull.head.ref,
|
||||
correlationId: input.correlationId
|
||||
}),
|
||||
retries: 2,
|
||||
@@ -162,6 +191,8 @@ export async function runReview(input: {
|
||||
correlationId: input.correlationId
|
||||
});
|
||||
|
||||
input.dedupe.complete(dedupeKey);
|
||||
|
||||
log("info", "Review completed", {
|
||||
correlation_id: input.correlationId,
|
||||
owner,
|
||||
|
||||
Reference in New Issue
Block a user