{"record":{"id":"63872d78cbc3a51d","repo":"redis/node-redis","slug":"database-name-not-found-in-path","errorCode":null,"errorMessage":"Database ${name} not found in ${path}","messagePattern":"Database (.+?) not found in (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/test-utils/lib/re-cluster.ts","lineNumber":54,"sourceCode":"\n/**\n * Resolves the managed Redis Enterprise database the suite should target, reading\n * the database named by RE_DB_NAME (default \"standalone\") from the endpoints config\n * at REDIS_ENDPOINTS_CONFIG_PATH - the same format consumed by the scenario tests.\n */\nexport function loadREConnection(): REConnection {\n  if (cached) return cached;\n\n  const path = process.env.REDIS_ENDPOINTS_CONFIG_PATH;\n  if (!path) {\n    throw new Error('REDIS_ENDPOINTS_CONFIG_PATH must be set when RE_CLUSTER=true');\n  }\n\n  const data = JSON.parse(readFileSync(path, 'utf-8')) as REDatabasesConfig;\n  const name = process.env.RE_DB_NAME || 'standalone';\n  const db = data[name] ?? Object.values(data)[0];\n  if (!db) {\n    throw new Error(`Database ${name} not found in ${path}`);\n  }\n\n  let host: string;\n  let port: number;\n  if (db.raw_endpoints && db.raw_endpoints.length > 0) {\n    host = db.raw_endpoints[0].dns_name;\n    port = db.raw_endpoints[0].port;\n  } else if (db.endpoints && db.endpoints.length > 0) {\n    const parsed = new URL(db.endpoints[0]);\n    host = parsed.hostname;\n    port = parsed.port ? Number(parsed.port) : parsed.protocol === 'rediss:' ? 6380 : 6379;\n  } else {\n    throw new Error(`No endpoints found for database ${name} in ${path}`);\n  }\n\n  cached = {\n    host,\n    port,","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/redis/node-redis/blob/90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58/packages/test-utils/lib/re-cluster.ts#L36-L72","documentation":"loadREConnection() throws when the endpoints config JSON was loaded but contains no database entry under RE_DB_NAME (default 'standalone') and the fallback Object.values(data)[0] is also undefined — i.e., the config object is empty or has no usable database entries. The named lookup and the first-value fallback both failed.","triggerScenarios":"REDIS_ENDPOINTS_CONFIG_PATH points at a valid JSON file that is {} or lacks the RE_DB_NAME key and has no other top-level database objects; or the databases are nested under a key the loader does not expect (schema drift).","commonSituations":"Empty or stub endpoints config generated by the pipeline; RE_DB_NAME set to a name not present in the file; config schema changed so databases live under a wrapper key; config written for a different environment.","solutions":["Set RE_DB_NAME to a top-level key that exists in the endpoints JSON.","Regenerate the endpoints config so it includes the expected database (default 'standalone') as a top-level entry.","Inspect the JSON at REDIS_ENDPOINTS_CONFIG_PATH to confirm its top-level keys match the REDatabasesConfig shape (Record<string, REDatabaseConfig>).","If the config nests databases under a wrapper, flatten it or update the loader to read the correct shape."],"exampleFix":"// before — endpoints.json is {} or missing 'standalone'\n{}\n\n// after — top-level database entry present\n{\n  \"standalone\": {\n    \"tls\": false,\n    \"raw_endpoints\": [{ \"dns_name\": \"re-host\", \"port\": 12000 }]\n  }\n}","handlingStrategy":"validation","validationCode":"import { readFileSync } from 'node:fs';\nfunction dbExistsInConfig(path: string, name: string): boolean {\n  const data = JSON.parse(readFileSync(path, 'utf-8')) as Record<string, unknown>;\n  return Boolean(data[name] ?? Object.values(data)[0]);\n}\n// before loadREConnection():\nif (!dbExistsInConfig(path, process.env.RE_DB_NAME || 'standalone')) {\n  throw new Error(`Database '${process.env.RE_DB_NAME || 'standalone'}' missing from ${path}`);\n}","typeGuard":"const isDatabaseConfig = (v: unknown): v is Record<string, unknown> =>\n  typeof v === 'object' && v !== null && !Array.isArray(v);","tryCatchPattern":null,"preventionTips":["Set RE_DB_NAME to a top-level key that exists in the endpoints JSON.","Validate the config shape (top-level database objects) in a CI bootstrap step before tests.","Print the available keys when generation fails, so mismatches are obvious.","Keep the config schema aligned with REDatabasesConfig (Record<string, REDatabaseConfig>)."],"tags":["test-utils","configuration","redis-enterprise","environment"],"backgroundTag":null,"analyzedSha":"90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58","analyzedAt":"2026-08-11T15:37:21.243Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}