{"record":{"id":"ed7a7f840f3e708f","repo":"cube-js/cube","slug":"jwt-token-is-not-present-in-the-response","errorCode":null,"errorMessage":"JWT token is not present in the response","messagePattern":"JWT token is not present in the response","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-cloud/src/cloud.ts","lineNumber":84,"sourceCode":"\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',\n        headers: { 'Content-type': 'application/json' },\n        body: JSON.stringify({ token: authToken })\n      }\n    );\n\n    if (!response.ok) {\n      throw new Error(`HTTP error! status: ${response.status}`);\n    }\n\n    const res = await response.json() as any;\n\n    if (!res.jwt) {\n      throw new Error('JWT token is not present in the response');\n    }\n\n    return res.jwt;\n  }\n\n  private extendRequestByLivePreview() {\n    return this.livePreview ? '?live=true' : '';\n  }\n\n  public getUpstreamHashes({ auth }: { auth?: AuthObject } = {}): Promise<UpstreamHashesResponse> {\n    return this.request({\n      url: (deploymentId: string) => `build/deploy/${deploymentId}/files${this.extendRequestByLivePreview()}`,\n      method: 'GET',\n      auth,\n    });\n  }\n\n  public startUpload({ auth }: { auth?: AuthObject } = {}): Promise<StartUploadResponse> {","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-cloud/src/cloud.ts#L66-L102","documentation":"After a successful (ok) response from the /v1/token endpoint, getDeploymentToken parses the JSON and requires a jwt field; if the body lacks it, it throws this error. It means Cube Cloud accepted the request but returned an unexpected payload — the token exchange did not produce a usable JWT.","triggerScenarios":"The /v1/token endpoint returns 2xx with a JSON body that has no jwt property — e.g. an API contract change on the Cube Cloud side, an error JSON body returned with 2xx status, or a proxy/gateway returning a 2xx HTML/empty body.","commonSituations":"Intercepting proxies or captive portals returning 200 with non-expected content; Cube Cloud API version drift; using a token type that the endpoint accepts silently but doesn't issue a JWT for.","solutions":["Log/inspect the raw response body from /v1/token to see what was actually returned.","Regenerate the auth token and retry the exchange.","Verify CUBE_CLOUD_HOST points at the genuine Cube Cloud API (not a proxy or wrong service).","If the API contract changed, upgrade @cubejs-backend-cloud to the latest version."],"exampleFix":"// before\nconst res = await response.json() as any;\nreturn res.jwt; // may be undefined\n// after\nconst res = await response.json() as any;\nif (!res?.jwt) throw new Error(`Token endpoint returned no jwt: ${JSON.stringify(res).slice(0, 200)}`);\nreturn res.jwt;","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function hasJwt(res: unknown): res is { jwt: string } {\n  return typeof res === 'object' && res !== null && 'jwt' in res && typeof (res as any).jwt === 'string' && (res as any).jwt.length > 0;\n}\n// usage: if (!hasJwt(await response.json())) throw new Error('unexpected /v1/token response');","tryCatchPattern":"try {\n  const jwt = await client.getDeploymentToken(token);\n} catch (e) {\n  if (e instanceof Error && e.message === 'JWT token is not present in the response') {\n    // log raw response body; check CUBE_CLOUD_HOST and API version\n  } else throw e;\n}","preventionTips":["Log the raw /v1/token response body during setup to catch contract surprises early.","Keep @cubejs-backend-cloud up to date with the Cube Cloud API.","Bypass intercepting proxies for the Cube Cloud host."],"tags":["jwt","cube-cloud","api-contract","token"],"backgroundTag":"missing-jwt-in-response","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}