Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/queue/processors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3825,6 +3825,7 @@ export async function runAiReviewForAdvisory(
headSha: args.advisory.headSha,
baseSha: args.pr.baseSha ?? null,
title: args.pr.title,
body: args.pr.body ?? undefined,
author: args.author,
githubToken: isReesGithubTokenForwardingEnabled(env)
? await resolveReviewEnrichmentGithubToken(
Expand Down
2 changes: 2 additions & 0 deletions src/review/enrichment-wire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ interface EnrichmentInput {
headSha: string | null;
baseSha?: string | null;
title?: string | undefined;
body?: string | undefined;
author?: string | null | undefined;
githubToken?: string | undefined;
files: PullRequestFileRecord[];
Expand Down Expand Up @@ -232,6 +233,7 @@ export async function buildReviewEnrichment(
headSha: input.headSha,
baseSha: input.baseSha ?? null,
title: input.title,
...(input.body ? { body: input.body } : {}),
author: input.author ?? undefined,
...(input.githubToken ? { githubToken: input.githubToken } : {}),
files: input.files.map((file) => ({
Expand Down
18 changes: 18 additions & 0 deletions test/unit/enrichment-wire.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ describe("buildReviewEnrichment", () => {
{
...input,
baseSha: "baseabc",
body: "Fixes #12",
author: "alice",
githubToken: "gh-read-token",
},
Expand All @@ -106,6 +107,7 @@ describe("buildReviewEnrichment", () => {
const body = JSON.parse(calls[0]!.init.body as string);
expect(body.repoFullName).toBe("o/r");
expect(body.baseSha).toBe("baseabc");
expect(body.body).toBe("Fixes #12");
expect(body.author).toBe("alice");
expect(body.githubToken).toBe("gh-read-token");
expect(body.analyzers).toBeUndefined();
Expand All @@ -128,6 +130,22 @@ describe("buildReviewEnrichment", () => {
]);
});

it("omits body from the REES POST when the PR body is empty", async () => {
let posted: { body?: string } | undefined;
globalThis.fetch = vi.fn(async (_url, init) => {
posted = JSON.parse(String(init?.body ?? "{}")) as { body?: string };
return {
ok: true,
json: async () => ({ promptSection: "brief" }),
} as Response;
}) as unknown as typeof fetch;
await buildReviewEnrichment(env({ REES_URL: "https://rees" }), {
...input,
author: "alice",
});
expect(posted?.body).toBeUndefined();
});

it("sends an analyzer budget below the transport timeout and accepts partial degraded briefs", async () => {
let body: { budget?: { timeoutMs?: number; maxBriefChars?: number } } | undefined;
globalThis.fetch = vi.fn(async (_url: unknown, init: RequestInit) => {
Expand Down
3 changes: 3 additions & 0 deletions test/unit/enrichment-wiring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ describe("review-enrichment wired into the processors review (flag GITTENSORY_RE
analyzers?: string[];
baseSha?: string | null;
author?: string;
body?: string;
githubToken?: string;
};
} = {};
Expand All @@ -105,6 +106,7 @@ describe("review-enrichment wired into the processors review (flag GITTENSORY_RE
analyzers?: string[];
baseSha?: string | null;
author?: string;
body?: string;
githubToken?: string;
};
return new Response(
Expand Down Expand Up @@ -141,6 +143,7 @@ describe("review-enrichment wired into the processors review (flag GITTENSORY_RE
]);
expect(reesRequest.body?.baseSha).toBe("base7");
expect(reesRequest.body?.author).toBe("alice");
expect(reesRequest.body?.body).toBe("Implements the thing.");
expect(reesRequest.body?.githubToken).toBe("public-read-token");
// The brief's content flows into the user prompt, but the system prompt carries our FIXED
// enrichment suffix — the REES-supplied systemSuffix is untrusted and is never spliced in.
Expand Down
Loading