cube-js/cube · error

HTTP error! status: ${response.status}

Error message

HTTP error! status: ${response.status}

What it means

request() performs a node-fetch call to the Cube Cloud API and throws `HTTP error! status: <code>` whenever response.ok is false (any 4xx/5xx). It is a generic surfacing of a Cube Cloud API rejection — authentication, deployment, or server-side failure — without response body details.

Source

Thrown at packages/cubejs-backend-cloud/src/cloud.ts:53

    const { url, auth, ...restOptions } = options;

    const authorization = auth || this.auth;
    if (!authorization) {
      throw new Error('Auth isn\'t set');
    }
    // Ensure headers object exists in restOptions
    restOptions.headers = restOptions.headers || {};
    // Add authorization to headers
    (restOptions.headers as any).authorization = authorization.auth;
    (restOptions.headers as any)['Content-type'] = 'application/json';

    const response = await fetch(
      `${authorization.url}/${url(authorization.deploymentId || '')}`,
      restOptions,
    );

    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }

    return await response.json() as Promise<T>;
  }

  public getDeploymentsList({ auth }: { auth?: AuthObject } = {}) {
    return this.request({
      url: () => 'build/deploy/deployments',
      method: 'GET',
      auth
    });
  }

  public async getDeploymentToken(authToken: string) {
    const response = await fetch(
      `${process.env.CUBE_CLOUD_HOST || 'https://cubecloud.dev'}/v1/token`,
      {
        method: 'POST',

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Re-authenticate: exchange a fresh auth token via getDeploymentToken to get a new JWT.
  2. Verify CUBE_CLOUD_HOST / authorization.url points to the correct Cube Cloud instance.
  3. Confirm the deploymentId in the token still exists (check the Cube Cloud console).
  4. If 5xx, retry after a delay — it may be a transient Cube Cloud incident; check status page.

Example fix

// before
const client = new CubeCloudClient({ auth: oldJwt }); // expired
// after
const fresh = await client.getDeploymentToken(process.env.CUBE_CLOUD_DEPLOY_AUTH!);
const client2 = new CubeCloudClient({ auth: fresh, url: process.env.CUBE_CLOUD_HOST });
Defensive patterns

Strategy: retry

Validate before calling

// Sanity-check host and auth before calling
if (!process.env.CUBE_CLOUD_HOST) throw new Error('CUBE_CLOUD_HOST must be set');
if (!auth?.auth) throw new Error('Cloud JWT missing');

Type guard

function isCloudHttpError(e: unknown): e is Error & { message: string } {
  return e instanceof Error && /^HTTP error! status: \d{3}$/.test(e.message);
}

Try / catch

try {
  await client.getUpstreamHashes();
} catch (e) {
  if (isCloudHttpError(e)) {
    const status = Number(e.message.match(/\d{3}/)?.[0]);
    if (status === 401 || status === 403) await reauthenticate();
    else if (status >= 500) await retryWithBackoff();
    else throw e;
  } else throw e;
}

Prevention

When it happens

Trigger: Any authenticated Cube Cloud call (getDeploymentsList, getUpstreamHashes, startUpload, uploadFile, finishUpload, setEnvVars) returning 401/403 (invalid/expired JWT), 404 (wrong url or deploymentId), or 5xx from Cube Cloud.

Common situations: Expired deployment JWT after inactivity; wrong CUBE_CLOUD_HOST; stale deploymentId in the token after a deployment was deleted; Cube Cloud service outage.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/cc1ba702bb6f7343. Report an issue: GitHub.