oven-sh/bun · error · Error

[azure] ${method} ${path} failed: ${response.status} ${text}

Error message

[azure] ${method} ${path} failed: ${response.status} ${text}

What it means

An Azure ARM REST call (method + path are named in the message) returned a non-2xx, non-204 response inside the retry loop, and the full response body is appended — Azure ARM errors are JSON with an error.code/message that says precisely what failed.

Source

Thrown at scripts/azure.mjs:136

      await new Promise(r => setTimeout(r, wait));
      continue;
    }

    // 202 Accepted — async operation, poll for completion
    if (response.status === 202) {
      const operationUrl = response.headers.get("Azure-AsyncOperation") || response.headers.get("Location");
      if (operationUrl) {
        return waitForOperation(operationUrl);
      }
    }

    if (response.status === 204) {
      return null;
    }

    if (!response.ok) {
      const text = await response.text();
      throw new Error(`[azure] ${method} ${path} failed: ${response.status} ${text}`);
    }

    const text = await response.text();
    return text ? JSON.parse(text) : null;
  }

  throw new Error(`[azure] ${method} ${path} failed after 3 retries`);
}

async function waitForOperation(operationUrl, maxWaitMs = 3_600_000) {
  const start = Date.now();
  let fetchErrors = 0;

  while (Date.now() - start < maxWaitMs) {
    const token = await getAccessToken();

    let response;
    try {

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. Parse the appended body: the error.code field identifies the ARM failure
  2. For 401/403, verify the service principal's role on /subscriptions/<id>/resourceGroups/<name>
  3. Verify subscriptionId/resourceGroup values resolve to real resources (rgPath builds the URL from them)
  4. Fix the request payload/path parameter flagged by the 400

Example fix

// before
throw new Error(`[azure] ${method} ${path} failed: ${response.status} ${text}`);

// after
const code = JSON.parse(text)?.error?.code ?? text.slice(0, 120);
throw new Error(`[azure] ${method} ${path} failed: ${response.status} ${code}`);
Defensive patterns

Strategy: retry

Prevention

When it happens

Trigger: 400 from an invalid request body or path parameter; 401/403 from an expired cached token or missing role assignment on the resource group; 404 for a resource that does not exist yet; any non-retryable status that fell through the loop's retry conditions.

Common situations: Deploying to a resource group that was deleted; missing Contributor role for the service principal; a path built from an unset subscriptionId/resourceGroup because config came from env fallbacks.

Related errors


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/b55403ef4cf72edd. Report an issue: GitHub.