{"record":{"id":"0aca36acba7bcaf6","repo":"cube-js/cube","slug":"the-keybydatasource-cubejs-db-use-select-test-c","errorCode":null,"errorMessage":"The ${keyByDataSource('CUBEJS_DB_USE_SELECT_TEST_CONNECTION', dataSource)} must be either 'true' or 'false'.","messagePattern":"The (.+?) must be either 'true' or 'false'\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-shared/src/env.ts","lineNumber":476,"sourceCode":"  ),\n\n  /**\n   * Use `SELECT 1` query for testConnection.\n   * It might be used in any driver where there is a specific testConnection\n   * like a REST call, but for some reason it's not possible to use it in\n   * deployment environment.\n   */\n  dbUseSelectTestConnection: ({\n    dataSource,\n    preAggregations,\n  }: DataSourceOpts) => {\n    const val = get(keyByDataSource('CUBEJS_DB_USE_SELECT_TEST_CONNECTION', dataSource, preAggregations)).default('false').asString();\n    if (val.toLocaleLowerCase() === 'true') {\n      return true;\n    } else if (val.toLowerCase() === 'false') {\n      return false;\n    } else {\n      throw new TypeError(\n        `The ${\n          keyByDataSource('CUBEJS_DB_USE_SELECT_TEST_CONNECTION', dataSource)\n        } must be either 'true' or 'false'.`\n      );\n    }\n  },\n\n  /**\n   * Kafka host for direct downloads from ksqlDb\n   */\n  dbKafkaHost: ({ dataSource, preAggregations }: DataSourceOpts) => (\n    get(keyByDataSource('CUBEJS_DB_KAFKA_HOST', dataSource, preAggregations)).asString()\n  ),\n\n  /**\n   * Kafka user for direct downloads from ksqlDb\n   */\n  dbKafkaUser: ({ dataSource, preAggregations }: DataSourceOpts) => (","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-shared/src/env.ts#L458-L494","documentation":"CUBEJS_DB_USE_SELECT_TEST_CONNECTION toggles using a SELECT 1 query for connection health checks, and Cube only accepts 'true' or 'false'; any other value throws a TypeError with the data-source-specific variable name interpolated.","triggerScenarios":"Setting CUBEJS_DB_USE_SELECT_TEST_CONNECTION (or CUBEJS_DS_<DS>_USE_SELECT_TEST_CONNECTION) to '1', 'True ' with trailing space, 'YES', or a quoted '\"true\"' string.","commonSituations":"Copy-pasting toggle values from other frameworks that accept yes/1/on; misconfigured .env parsing that keeps quotes; typos like 'ture'.","solutions":["Set the variable to exactly true or false.","Check the .env file for surrounding quotes and remove them.","Normalize the value in deployment scripts (e.g. ${VAR,,} lowercase and trimmed in bash).","Confirm with node -p \"process.env.CUBEJS_DB_USE_SELECT_TEST_CONNECTION\" in the container."],"exampleFix":"// before\nCUBEJS_DB_USE_SELECT_TEST_CONNECTION=yes\n// after\nCUBEJS_DB_USE_SELECT_TEST_CONNECTION=true","handlingStrategy":"validation","validationCode":"const v = process.env.CUBEJS_DB_USE_SELECT_TEST_CONNECTION;\nif (v !== undefined && !/^(true|false)$/i.test(v.trim()))\n  throw new Error(`CUBEJS_DB_USE_SELECT_TEST_CONNECTION must be 'true' or 'false', got: ${JSON.stringify(v)}`);","typeGuard":null,"tryCatchPattern":"try {\n  useSelectForTestConnection(dataSource);\n} catch (e) {\n  if (e instanceof TypeError && e.message.includes('USE_SELECT_TEST_CONNECTION')) {\n    console.error('Set CUBEJS_DB_USE_SELECT_TEST_CONNECTION to true or false');\n  }\n  throw e;\n}","preventionTips":["Only use the literal strings true/false for this toggle.","Check .env files for stray quotes around values.","Add an env-var lint step to CI that enforces boolean formats."],"tags":["configuration","environment-variables","typeerror","validation"],"backgroundTag":"invalid-boolean-env-var","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}