fix: resolve undefined variable refs in billing retry paths (#2335)

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 <noreply@anthropic.com>
This commit is contained in:
A 2026-03-08 05:56:21 -07:00 committed by GitHub
parent 4f528b1c77
commit bfef29a1b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 12 deletions

View file

@ -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;
}

View file

@ -235,7 +235,7 @@ async function testDoToken(): Promise<boolean> {
* Throws if the account is locked (billing issue). Warns on other statuses.
*/
export async function checkAccountStatus(): Promise<void> {
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,

View file

@ -521,7 +521,7 @@ export async function resolveProject(): Promise<void> {
* Throws if billing is not enabled (so orchestrate.ts can catch and continue).
*/
export async function checkBillingEnabled(): Promise<void> {
if (!gcpProject) {
if (!_state.project) {
return;
}
try {
@ -529,12 +529,12 @@ export async function checkBillingEnabled(): Promise<void> {
"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<void> {
"billing",
"projects",
"describe",
gcpProject,
_state.project,
"--format=value(billingEnabled)",
]);
if (retry.stdout.trim().toLowerCase() === "false") {