Skip to content

Commit e1874ea

Browse files
committed
fix: address review feedback on billing error handling
- Paginate hasPRCommentWithMarker using octokit.paginate to match the GitLab counterpart and avoid duplicate billing notices on busy PRs - Preserve structured error objects in wrapper fallback via JSON.stringify instead of discarding them - Improve cross-reference comments between the duplicate terminal reason type definitions in worker-utils and db packages
1 parent 22459b5 commit e1874ea

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

cloud-agent-next/wrapper/src/connection.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,9 @@ export function createConnectionManager(
370370
const errorText =
371371
typeof properties.error === 'string'
372372
? properties.error
373-
: `Insufficient credits: ${eventType}`;
373+
: properties.error
374+
? JSON.stringify(properties.error)
375+
: `Insufficient credits: ${eventType}`;
374376
callbacks.onTerminalError(errorText);
375377
return;
376378
}

packages/db/src/schema-types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,9 @@ export type StripeSubscriptionStatus =
908908

909909
/**
910910
* Valid values for cloud_agent_code_reviews.terminal_reason.
911-
* Canonical list — keep in sync with CloudAgentTerminalReason in
912-
* packages/worker-utils/src/cloud-agent-next-client.ts if that copy diverges.
911+
* KEEP IN SYNC with CloudAgentTerminalReason in
912+
* packages/worker-utils/src/cloud-agent-next-client.ts — both lists must
913+
* contain the same literal values.
913914
*/
914915
export const CODE_REVIEW_TERMINAL_REASONS = [
915916
'billing',

packages/worker-utils/src/cloud-agent-next-client.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ export type CloudAgentInterruptOutput = {
8787

8888
/**
8989
* Valid terminal reasons for code review failures.
90-
* Keep in sync with CodeReviewTerminalReason in packages/db/src/schema-types.ts.
90+
* KEEP IN SYNC with CODE_REVIEW_TERMINAL_REASONS / CodeReviewTerminalReason
91+
* in packages/db/src/schema-types.ts — both lists must contain the same
92+
* literal values. A mismatch will cause the orchestrator to send a reason
93+
* that normalizePayload rejects via its allowlist check.
9194
*/
9295
export type CloudAgentTerminalReason =
9396
| 'billing'

src/lib/integrations/platforms/github/adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ export async function hasPRCommentWithMarker(
304304
const tokenData = await generateGitHubInstallationToken(installationId, appType);
305305
const octokit = new Octokit({ auth: tokenData.token });
306306

307-
const { data: comments } = await octokit.issues.listComments({
307+
const comments = await octokit.paginate(octokit.issues.listComments, {
308308
owner,
309309
repo,
310310
issue_number: prNumber,

0 commit comments

Comments
 (0)