{"record":{"id":"58dfcf9d231101d0","repo":"cube-js/cube","slug":"json-stringify-deployments","errorCode":null,"errorMessage":"JSON.stringify(deployments)","messagePattern":"JSON\\.stringify\\(deployments\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-cli/src/config.ts","lineNumber":55,"sourceCode":"    }\n\n    const auth = await this.deployAuth();\n    let url = Object.keys(auth)[0];\n    if (Object.keys(auth).length > 1) {\n      // eslint-disable-next-line prefer-destructuring\n      url = (await inquirer.prompt([{\n        type: 'list',\n        name: 'url',\n        message: 'Please select an organization',\n        choices: Object.keys(auth)\n      }])).url;\n    }\n\n    const authToken = auth[url];\n    const deployments = await this.cubeCloudClient.getDeploymentsList({ auth: { ...authToken, url } });\n\n    if (!Array.isArray(deployments)) {\n      throw new Error(JSON.stringify(deployments));\n    }\n\n    if (!deployments.length) {\n      // eslint-disable-next-line no-throw-literal\n      throw `${url} doesn't have any managed deployments. Please create one.`;\n    }\n\n    let deploymentId = deployments[0].id;\n    if (deployments.length > 1) {\n      const { deployment } = await inquirer.prompt([{\n        type: 'list',\n        name: 'deployment',\n        message: 'Please select a deployment to deploy to',\n        choices: deployments\n      }]);\n      deploymentId = deployments.find(d => d.name === deployment).id;\n    }\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-cli/src/config.ts#L37-L73","documentation":"After fetching the deployment list from Cube Cloud, deployAuthForCurrentDir asserts the response is an array. If the API returns anything else (an error object, HTML, null), the driver throws the raw JSON-serialized response so the developer can see what the API actually returned instead of failing later with a confusing downstream error.","triggerScenarios":"cubeCloudClient.getDeploymentsList returns a non-array — typically an authentication/authorization error payload, rate-limit response, or gateway error page instead of the deployments array.","commonSituations":"Expired or invalid Cube Cloud token causing an error object response; deployment URL misconfigured pointing to a non-cloud endpoint; network proxy returning an error page; API version change in the response shape.","solutions":["Inspect the thrown JSON — it contains the API's actual error payload (usually an auth or permission error)","Re-authenticate with `cubejs login` to refresh the token","Verify .cubecloud url points at the correct Cube Cloud API host","Check Cube Cloud status/permissions for the account — the token may lack access to any deployments"],"exampleFix":"// before: expired token returns {\"error\":\"unauthorized\"}\n$ cubejs deploy\n// after: re-authenticate then deploy\n$ cubejs login\n$ cubejs deploy","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await cubejsDeploy();\n} catch (e) {\n  let payload;\n  try { payload = JSON.parse(e.message); } catch { throw e; }\n  if (payload && payload.error) {\n    // auth/permission error from Cube Cloud API: re-authenticate\n  }\n  throw e;\n}","preventionTips":["Refresh tokens before long CI jobs with `cubejs login`","Verify .cubecloud url points at the cloud API host","Confirm the account has access to at least one deployment"],"tags":["cube-cloud","api-response","authentication"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}