{"record":{"id":"3cbe4d3f41e16c27","repo":"redis/node-redis","slug":"invalid-unix-url","errorCode":null,"errorMessage":"Invalid unix URL","messagePattern":"Invalid unix URL","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/client/lib/client/index.ts","lineNumber":541,"sourceCode":"      if (isNaN(database)) {\n        throw new TypeError('Invalid pathname');\n      }\n\n      parsed.database = database;\n    }\n\n    return parsed;\n  }\n\n  static #parseUnixURL(url: string): AnyRedisClientOptions & {\n    socket: Exclude<AnyRedisClientOptions['socket'], undefined> & {\n      tls: boolean\n    }\n  } {\n    // unix://[user[:password]@]/path/to/sock[?db=N]\n    const match = /^unix:\\/\\/(?:([^:@/]*)(?::([^@/]*))?@)?(\\/[^?#]*)(?:\\?([^#]*))?(?:#.*)?$/.exec(url);\n    if (!match || match[3] === '/') {\n      throw new TypeError('Invalid unix URL');\n    }\n\n    const [, username, password, rawPath, rawQuery] = match,\n      parsed: AnyRedisClientOptions & {\n        socket: Exclude<AnyRedisClientOptions['socket'], undefined> & {\n          tls: boolean\n        }\n      } = {\n        socket: {\n          path: decodeURIComponent(rawPath),\n          tls: false\n        }\n      };\n\n    if (username) {\n      parsed.username = decodeURIComponent(username);\n    }\n","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/redis/node-redis/blob/90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58/packages/client/lib/client/index.ts#L523-L559","documentation":"RedisClient.#parseUnixURL expects unix://[user[:password]@]/path/to/sock[?db=N]. The regex must match AND the path group (match[3]) must not be just '/'. An empty socket path or a URL shaped like unix://host/path (the regex forbids a bare host before the path) is rejected.","triggerScenarios":"Passing 'unix://' with no path, 'unix:///' (bare slash), or a URL whose authority section breaks the expected shape.","commonSituations":"Forgetting to include the socket file path; treating a unix:// URL like a tcp URL with a host; URL-encoding the path so the regex no longer matches.","solutions":["Provide the full socket file path, e.g. unix:///var/run/redis/redis.sock.","If you need credentials, place them before the path: unix://user:pass@/var/run/redis/redis.sock."],"exampleFix":"// before\ncreateClient({ url: 'unix:///' });\n\n// after\ncreateClient({ url: 'unix:///var/run/redis/redis.sock' });","handlingStrategy":"validation","validationCode":"function assertUnixUrl(url) {\n  const m = /^unix:\\/\\/(?:([^:@/]*)(?::([^@/]*))?@)?(\\/[^?#]*)(?:\\?([^#]*))?(?:#.*)?$/.exec(url);\n  if (!m || m[3] === '/') {\n    throw new TypeError(`Invalid unix URL ${url}; expected unix://[user[:pass]@]/path/to/sock[?db=N]`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the full socket file path in a unix:// URL.","Do not URL-encode the leading slash of the socket path.","Test socket URLs in isolation before wiring them into config."],"tags":["url","unix-socket","config","validation"],"backgroundTag":null,"analyzedSha":"90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58","analyzedAt":"2026-08-11T15:37:21.243Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}