{"record":{"id":"77081c6152b4866a","repo":"cube-js/cube","slug":"auth-isn-t-set","errorCode":null,"errorMessage":"Auth isn't set","messagePattern":"Auth isn't set","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-cloud/src/cloud.ts","lineNumber":39,"sourceCode":"  };\n}\n\nexport class CubeCloudClient {\n  public constructor(\n    protected readonly auth?: AuthObject,\n    protected readonly livePreview?: boolean\n  ) {\n  }\n\n  private async request<T>(options: {\n    url: (deploymentId: string) => string,\n    auth?: AuthObject,\n  } & RequestInit): Promise<T> {\n    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  }","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-cloud/src/cloud.ts#L21-L57","documentation":"CubeCloudClient.request requires an AuthObject (from this.auth or the per-call auth option) before calling Cube Cloud; if neither is present it throws \"Auth isn't set\". The client was constructed without cloud credentials, so no authenticated API call can be made.","triggerScenarios":"Calling getDeploymentsList, getUpstreamHashes, startUpload, uploadFile, finishUpload, or setEnvVars on a CubeCloudClient created without an AuthObject and without passing { auth } to the call.","commonSituations":"Running `cubejs deploy` or related CLI commands without a Cube Cloud auth token configured; token file/env var missing (e.g. CUBE_CLOUD_DEPLOY_AUTH not set); LivePreviewWatcher.setAuth never called before operations that hit the cloud client.","solutions":["Provide the Cube Cloud auth token — construct CubeCloudClient with an AuthObject or pass { auth } to the call.","For CLI deploys, ensure the cloud token is configured (cubejs cloud token / environment variable) before running the command.","For live preview, ensure setAuth(token) is called on LivePreviewWatcher before anything triggers cloud requests.","Verify the token is valid — getDeploymentToken should be used first to exchange an auth token for a JWT AuthObject."],"exampleFix":"// before\nconst client = new CubeCloudClient();\nawait client.getDeploymentsList(); // throws 'Auth isn't set'\n// after\nconst jwt = await client.getDeploymentToken(process.env.CUBE_CLOUD_DEPLOY_AUTH!);\nconst client2 = new CubeCloudClient({ auth: jwt, url: process.env.CUBE_CLOUD_HOST });\nawait client2.getDeploymentsList();","handlingStrategy":"validation","validationCode":"function assertAuth(auth?: AuthObject | null): asserts auth is AuthObject {\n  if (!auth || !auth.auth) throw new Error('Cube Cloud auth token required before calling the cloud API');\n}\n// usage\nassertAuth(client['auth'] as AuthObject | undefined);","typeGuard":"function isAuthSet(auth: AuthObject | null | undefined): auth is AuthObject {\n  return !!auth && typeof auth.auth === 'string' && auth.auth.length > 0;\n}","tryCatchPattern":"try {\n  await client.getDeploymentsList();\n} catch (e) {\n  if (e instanceof Error && e.message === \"Auth isn't set\") {\n    // re-authenticate then retry\n  } else throw e;\n}","preventionTips":["Always exchange CUBE_CLOUD_DEPLOY_AUTH for a JWT via getDeploymentToken before constructing CubeCloudClient.","Fail fast at startup: check for the cloud token env var before running deploy commands.","Never construct CubeCloudClient without an AuthObject in production paths."],"tags":["auth","cube-cloud","configuration"],"backgroundTag":"missing-auth-credentials","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}