cube-js/cube · error · TypeError
The ${keyByDataSource('CUBEJS_DB_SSL', dataSource)} must be
Error message
The ${keyByDataSource('CUBEJS_DB_SSL', dataSource)} must be either 'true' or 'false'. What it means
Cube reads CUBEJS_DB_SSL (per data source via keyByDataSource) and only accepts the literal strings 'true' or 'false' (case-insensitive); anything else throws a TypeError. The message interpolates the actual data-source-specific variable name, e.g. CUBEJS_DS_MYSQL_DB_SSL.
Source
Thrown at packages/cubejs-backend-shared/src/env.ts:411
dbType: ({ dataSource }: DataSourceOpts) => (
// We don't support different driverType for pre-aggregations right now
get(keyByDataSource('CUBEJS_DB_TYPE', dataSource, false)).asString()
),
/**
* Use SSL connection flag.
*/
dbSsl: ({
dataSource,
preAggregations,
}: DataSourceOpts) => {
const val = get(keyByDataSource('CUBEJS_DB_SSL', dataSource, preAggregations)).default('false').asString();
if (val.toLocaleLowerCase() === 'true') {
return true;
} else if (val.toLowerCase() === 'false') {
return false;
} else {
throw new TypeError(
`The ${
keyByDataSource('CUBEJS_DB_SSL', dataSource)
} must be either 'true' or 'false'.`
);
}
},
/**
* Reject unauthorized SSL connection flag.
*/
dbSslRejectUnauthorized: ({
dataSource,
preAggregations,
}: DataSourceOpts) => {
const val = get(keyByDataSource('CUBEJS_DB_SSL_REJECT_UNAUTHORIZED', dataSource, preAggregations)).default('false').asString();
if (val.toLocaleLowerCase() === 'true') {
return true;
} else if (val.toLowerCase() === 'false') {View on GitHub (pinned to 7d981676b3)
Solutions
- Set the variable to exactly true or false (no quotes, no whitespace).
- Inspect the deployed value: node -e "console.log(JSON.stringify(process.env.CUBEJS_DB_SSL))" to reveal hidden characters.
- Trim/normalize the value in your CI secret configuration.
- Update scripts that set 1/0 or yes/no to true/false.
Example fix
// before CUBEJS_DB_SSL="true" # literal quotes break parsing CUBEJS_DB_SSL=yes // after CUBEJS_DB_SSL=true
Defensive patterns
Strategy: validation
Validate before calling
for (const [k, v] of Object.entries(process.env)) {
if (k.endsWith('_DB_SSL') && v !== undefined && !/^(true|false)$/i.test(v.trim()))
throw new Error(`${k} must be 'true' or 'false', got: ${JSON.stringify(v)}`);
} Type guard
function isBoolString(v: unknown): v is 'true' | 'false' {
return v === 'true' || v === 'false' || v === 'TRUE' || v === 'FALSE';
} Try / catch
try {
dbSslEnabled(dataSource);
} catch (e) {
if (e instanceof TypeError && e.message.includes("either 'true' or 'false'")) {
console.error(`Set ${keyByDataSource('CUBEJS_DB_SSL', dataSource)} to true or false`);
}
throw e;
} Prevention
- Write booleans as bare true/false in env files, never quoted or 1/0.
- Check deployed values with node -p "JSON.stringify(process.env.X)" for hidden quotes/whitespace.
- Normalize quoting in secret managers and Helm templates.
When it happens
Trigger: Setting CUBEJS_DB_SSL (or CUBEJS_DS_<DS>_DB_SSL) to values like '1', 'yes', 'on', 'enabled', or leaving stray quotes/whitespace such as '"true"'.
Common situations: Shell quoting adding literal quotes around the value; using 1/0 or yes/no conventions from other tools; CI secrets platforms injecting trailing whitespace or newline characters.
Related errors
- The ${keyByDataSource('CUBEJS_DB_SSL_REJECT_UNAUTHORIZED', d
- The ${keyByDataSource('CUBEJS_DB_USE_SELECT_TEST_CONNECTION'
- The ${origin} environment variable can not be converted for
- Value "${value}" is not valid for CUBEJS_MAX_REQUEST_SIZE. M
- The ${keyByDataSource('CUBEJS_DB_NAME', dataSource)} is requ
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/738b4d66417f399b.
Report an issue: GitHub.