{"record":{"id":"cc1ba702bb6f7343","repo":"cube-js/cube","slug":"http-error-status-response-status","errorCode":null,"errorMessage":"HTTP error! status: ${response.status}","messagePattern":"HTTP error! status: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-cloud/src/cloud.ts","lineNumber":53,"sourceCode":"    const { url, auth, ...restOptions } = options;\n\n    const authorization = auth || this.auth;\n    if (!authorization) {\n      throw new Error('Auth isn\\'t set');\n    }\n    // Ensure headers object exists in restOptions\n    restOptions.headers = restOptions.headers || {};\n    // Add authorization to headers\n    (restOptions.headers as any).authorization = authorization.auth;\n    (restOptions.headers as any)['Content-type'] = 'application/json';\n\n    const response = await fetch(\n      `${authorization.url}/${url(authorization.deploymentId || '')}`,\n      restOptions,\n    );\n\n    if (!response.ok) {\n      throw new Error(`HTTP error! status: ${response.status}`);\n    }\n\n    return await response.json() as Promise<T>;\n  }\n\n  public getDeploymentsList({ auth }: { auth?: AuthObject } = {}) {\n    return this.request({\n      url: () => 'build/deploy/deployments',\n      method: 'GET',\n      auth\n    });\n  }\n\n  public async getDeploymentToken(authToken: string) {\n    const response = await fetch(\n      `${process.env.CUBE_CLOUD_HOST || 'https://cubecloud.dev'}/v1/token`,\n      {\n        method: 'POST',","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-cloud/src/cloud.ts#L35-L71","documentation":"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.","triggerScenarios":"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.","commonSituations":"Expired deployment JWT after inactivity; wrong CUBE_CLOUD_HOST; stale deploymentId in the token after a deployment was deleted; Cube Cloud service outage.","solutions":["Re-authenticate: exchange a fresh auth token via getDeploymentToken to get a new JWT.","Verify CUBE_CLOUD_HOST / authorization.url points to the correct Cube Cloud instance.","Confirm the deploymentId in the token still exists (check the Cube Cloud console).","If 5xx, retry after a delay — it may be a transient Cube Cloud incident; check status page."],"exampleFix":"// before\nconst client = new CubeCloudClient({ auth: oldJwt }); // expired\n// after\nconst fresh = await client.getDeploymentToken(process.env.CUBE_CLOUD_DEPLOY_AUTH!);\nconst client2 = new CubeCloudClient({ auth: fresh, url: process.env.CUBE_CLOUD_HOST });","handlingStrategy":"retry","validationCode":"// Sanity-check host and auth before calling\nif (!process.env.CUBE_CLOUD_HOST) throw new Error('CUBE_CLOUD_HOST must be set');\nif (!auth?.auth) throw new Error('Cloud JWT missing');","typeGuard":"function isCloudHttpError(e: unknown): e is Error & { message: string } {\n  return e instanceof Error && /^HTTP error! status: \\d{3}$/.test(e.message);\n}","tryCatchPattern":"try {\n  await client.getUpstreamHashes();\n} catch (e) {\n  if (isCloudHttpError(e)) {\n    const status = Number(e.message.match(/\\d{3}/)?.[0]);\n    if (status === 401 || status === 403) await reauthenticate();\n    else if (status >= 500) await retryWithBackoff();\n    else throw e;\n  } else throw e;\n}","preventionTips":["Refresh the deployment JWT periodically instead of reusing long-lived tokens.","Pin CUBE_CLOUD_HOST to the exact instance URL for your organization.","Verify deploymentId still exists before bulk operations.","Wrap cloud calls in backoff retry for 5xx."],"tags":["http","cube-cloud","network"],"backgroundTag":"http-error-status","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}