{"record":{"id":"19fb5b098c9dfb90","repo":"redis/node-redis","slug":"config-file-not-found-at-path-path","errorCode":null,"errorMessage":"Config file not found at path: ${path}","messagePattern":"Config file not found at path: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/test-utils/lib/cae-client-testing.ts","lineNumber":26,"sourceCode":"}\n\nexport type RedisEndpointsConfig = Record<string, RawRedisEndpoint>;\n\nexport function loadFromJson(jsonString: string): RedisEndpointsConfig {\n  try {\n    return JSON.parse(jsonString) as RedisEndpointsConfig;\n  } catch (error) {\n    throw new Error(`Invalid JSON configuration: ${error}`);\n  }\n}\n\nexport async function loadFromFile(path: string): Promise<RedisEndpointsConfig> {\n  try {\n    const configFile = await readFile(path, 'utf-8');\n    return loadFromJson(configFile);\n  } catch (error) {\n    if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {\n      throw new Error(`Config file not found at path: ${path}`);\n    }\n    throw error;\n  }\n}","sourceCodeStart":8,"sourceCodeEnd":30,"githubUrl":"https://github.com/redis/node-redis/blob/90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58/packages/test-utils/lib/cae-client-testing.ts#L8-L30","documentation":"loadFromFile reads a file via fs/promises.readFile and calls loadFromJson on its contents. When readFile rejects with code ENOENT (file does not exist), this error is thrown, naming the path. Any other read error (permissions, etc.) or a JSON parse error propagates as-is.","triggerScenarios":"Calling loadFromFile(path) where path points to a non-existent file; passing a relative path resolved against an unexpected working directory; typo in the filename.","commonSituations":"Wrong working directory when running tests; config file committed to a different location; path built from an env var that is unset (yielding 'undefined' in the string); case-sensitivity mismatch on Linux.","solutions":["Verify the path with an absolute path first to rule out working-directory issues","Check the file exists before calling: await fs.access(path) — or create it","Print path.resolve(process.cwd(), path) to confirm where Node is actually looking"],"exampleFix":"// before\nconst cfg = await loadFromFile('./redis-endpoints.json'); // ENOENT\n\n// after\nconst { resolve } = require('node:path');\nconst p = resolve(__dirname, 'redis-endpoints.json');\nawait fs.access(p); // throws clearly if missing\nconst cfg = await loadFromFile(p);","handlingStrategy":"validation","validationCode":"import { access } from 'node:fs/promises';\nasync function safeLoadFromFile(path: string) {\n  await access(path); // throws ENOENT clearly if missing\n  return loadFromFile(path);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const cfg = await loadFromFile(path);\n} catch (e) {\n  if (e instanceof Error && /Config file not found/.test(e.message)) {\n  }\n  throw e;\n}","preventionTips":["Always resolve config paths with path.resolve against __dirname, not process.cwd()","Use absolute paths in test fixtures to avoid working-directory ambiguity","Commit a sample config file and assert its presence in test setup"],"tags":["filesystem","configuration","test-utils","enoent"],"backgroundTag":null,"analyzedSha":"90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58","analyzedAt":"2026-08-11T15:37:21.243Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}