cube-js/cube · error
JSON.stringify(deployments)
Error message
JSON.stringify(deployments)
What it means
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.
Source
Thrown at packages/cubejs-cli/src/config.ts:55
}
const auth = await this.deployAuth();
let url = Object.keys(auth)[0];
if (Object.keys(auth).length > 1) {
// eslint-disable-next-line prefer-destructuring
url = (await inquirer.prompt([{
type: 'list',
name: 'url',
message: 'Please select an organization',
choices: Object.keys(auth)
}])).url;
}
const authToken = auth[url];
const deployments = await this.cubeCloudClient.getDeploymentsList({ auth: { ...authToken, url } });
if (!Array.isArray(deployments)) {
throw new Error(JSON.stringify(deployments));
}
if (!deployments.length) {
// eslint-disable-next-line no-throw-literal
throw `${url} doesn't have any managed deployments. Please create one.`;
}
let deploymentId = deployments[0].id;
if (deployments.length > 1) {
const { deployment } = await inquirer.prompt([{
type: 'list',
name: 'deployment',
message: 'Please select a deployment to deploy to',
choices: deployments
}]);
deploymentId = deployments.find(d => d.name === deployment).id;
}
View on GitHub (pinned to 7d981676b3)
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
Example fix
// before: expired token returns {"error":"unauthorized"}
$ cubejs deploy
// after: re-authenticate then deploy
$ cubejs login
$ cubejs deploy Defensive patterns
Strategy: try-catch
Try / catch
try {
await cubejsDeploy();
} catch (e) {
let payload;
try { payload = JSON.parse(e.message); } catch { throw e; }
if (payload && payload.error) {
// auth/permission error from Cube Cloud API: re-authenticate
}
throw e;
} Prevention
- 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
When it happens
Trigger: cubeCloudClient.getDeploymentsList returns a non-array — typically an authentication/authorization error payload, rate-limit response, or gateway error page instead of the deployments array.
Common situations: 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.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- Provided token isn't for ${dotCubeCloud.url}
- Auth isn't set
- HTTP error! status: ${response.status}
- JWT token is not present in the response
- options.checkAuth must be a function
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/58dfcf9d231101d0.
Report an issue: GitHub.