From bfef29a1b3df87a1ad3bcb6399de63d372442597 Mon Sep 17 00:00:00 2001 From: A <258483684+la14-1@users.noreply.github.com> Date: Sun, 8 Mar 2026 05:56:21 -0700 Subject: [PATCH] fix: resolve undefined variable refs in billing retry paths (#2335) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Five undefined variable references across three cloud modules caused billing retry paths to silently fail: - digitalocean: doToken, doDropletId, doServerIp → _state.token/dropletId/serverIp - gcp: gcpProject → _state.project - aws: instanceName → _state.instanceName These caused checkAccountStatus() and checkBillingEnabled() to always return early, and billing retry saves to use wrong/undefined values. Agent: code-health Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 --- packages/cli/src/aws/aws.ts | 4 ++-- packages/cli/src/digitalocean/digitalocean.ts | 12 ++++++------ packages/cli/src/gcp/gcp.ts | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/cli/src/aws/aws.ts b/packages/cli/src/aws/aws.ts index 30935389..7fb73396 100644 --- a/packages/cli/src/aws/aws.ts +++ b/packages/cli/src/aws/aws.ts @@ -883,7 +883,7 @@ export async function createInstance(name: string, tier?: CloudInitTier): Promis "--user-data", userdata, ]); - instanceName = name; + _state.instanceName = name; logInfo(`Instance creation initiated: ${name}`); return; } @@ -934,7 +934,7 @@ export async function createInstance(name: string, tier?: CloudInitTier): Promis userData: userdata, }), ); - instanceName = name; + _state.instanceName = name; logInfo(`Instance creation initiated: ${name}`); return; } diff --git a/packages/cli/src/digitalocean/digitalocean.ts b/packages/cli/src/digitalocean/digitalocean.ts index 1f128df9..376ca801 100644 --- a/packages/cli/src/digitalocean/digitalocean.ts +++ b/packages/cli/src/digitalocean/digitalocean.ts @@ -235,7 +235,7 @@ async function testDoToken(): Promise { * Throws if the account is locked (billing issue). Warns on other statuses. */ export async function checkAccountStatus(): Promise { - if (!doToken) { + if (!_state.token) { return; } try { @@ -886,13 +886,13 @@ export async function createServer( const retryText = await doApi("POST", "/droplets", body); const retryData = parseJsonObj(retryText); if (retryData?.droplet?.id) { - doDropletId = String(retryData.droplet.id); - logInfo(`Droplet created: ID=${doDropletId}`); - await waitForDropletActive(doDropletId); + _state.dropletId = String(retryData.droplet.id); + logInfo(`Droplet created: ID=${_state.dropletId}`); + await waitForDropletActive(_state.dropletId); saveVmConnection( - doServerIp, + _state.serverIp, "root", - doDropletId, + _state.dropletId, name, "digitalocean", undefined, diff --git a/packages/cli/src/gcp/gcp.ts b/packages/cli/src/gcp/gcp.ts index baa9bfda..a908983d 100644 --- a/packages/cli/src/gcp/gcp.ts +++ b/packages/cli/src/gcp/gcp.ts @@ -521,7 +521,7 @@ export async function resolveProject(): Promise { * Throws if billing is not enabled (so orchestrate.ts can catch and continue). */ export async function checkBillingEnabled(): Promise { - if (!gcpProject) { + if (!_state.project) { return; } try { @@ -529,12 +529,12 @@ export async function checkBillingEnabled(): Promise { "billing", "projects", "describe", - gcpProject, + _state.project, "--format=value(billingEnabled)", ]); const output = result.stdout.trim().toLowerCase(); if (output === "false") { - logWarn(`Billing is not enabled for project '${gcpProject}'.`); + logWarn(`Billing is not enabled for project '${_state.project}'.`); const shouldRetry = await handleBillingError("gcp"); if (!shouldRetry) { throw new Error("GCP billing not enabled"); @@ -544,7 +544,7 @@ export async function checkBillingEnabled(): Promise { "billing", "projects", "describe", - gcpProject, + _state.project, "--format=value(billingEnabled)", ]); if (retry.stdout.trim().toLowerCase() === "false") {