{"record":{"id":"8f77ad8e4f5eeee2","repo":"chroma-core/chroma","slug":"invalid-url-path","errorCode":null,"errorMessage":"Invalid URL: ${path}","messagePattern":"Invalid URL: (.+?)","errorType":"validation","errorClass":"ChromaValueError","httpStatus":null,"severity":"error","filePath":"clients/new-js/packages/chromadb/src/utils.ts","lineNumber":778,"sourceCode":"    throw new ChromaValueError(\"Number of requested results has to positive\");\n  }\n};\n\nexport const parseConnectionPath = (path: string) => {\n  try {\n    const url = new URL(path);\n\n    const ssl = url.protocol === \"https:\";\n    const host = url.hostname;\n    const port = url.port;\n\n    return {\n      ssl,\n      host,\n      port: Number(port),\n    };\n  } catch {\n    throw new ChromaValueError(`Invalid URL: ${path}`);\n  }\n};\nconst packEmbedding = (embedding: number[]): ArrayBuffer => {\n  const buffer = new ArrayBuffer(embedding.length * 4);\n  const view = new Float32Array(buffer);\n  for (let i = 0; i < embedding.length; i++) {\n    view[i] = embedding[i];\n  }\n  return buffer;\n};\n\nexport const embeddingsToBase64Bytes = (embeddings: number[][]) => {\n  return embeddings.map((embedding) => {\n    const buffer = packEmbedding(embedding);\n\n    const uint8Array = new Uint8Array(buffer);\n    const binaryString = Array.from(uint8Array, (byte) =>\n      String.fromCharCode(byte),","sourceCodeStart":760,"sourceCodeEnd":796,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/new-js/packages/chromadb/src/utils.ts#L760-L796","documentation":"parseConnectionPath (utils.ts:764-780) runs new URL(path) on the deprecated ChromaClient `path` argument (chroma-client.ts:103-111, which also logs a deprecation warning recommending host/port/ssl). The WHATWG URL constructor requires an absolute URL with a scheme; if it cannot parse the input, the catch block rethrows ChromaValueError 'Invalid URL: <path>'.","triggerScenarios":"new ChromaClient({ path: 'localhost:8000' }) (no scheme); path: 'chroma.example.com'; path: 'http//host:8000' (typo); path: ''.","commonSituations":"Building the connection string from environment variables that lack the http:// prefix; migrating older code that used `path` instead of the host/port/ssl options.","solutions":["Use the non-deprecated options: new ChromaClient({ host: 'localhost', port: 8000, ssl: false })","If you must use path, always include the scheme: 'http://localhost:8000' or 'https://...'","Pre-validate with URL.canParse(path) (or a try/catch around new URL(path)) before constructing the client"],"exampleFix":"// before\nnew ChromaClient({ path: 'localhost:8000' });\n\n// after\nnew ChromaClient({ host: 'localhost', port: 8000 });\n// or, if path is required: new ChromaClient({ path: 'http://localhost:8000' })","handlingStrategy":"validation","validationCode":"// Node 18.17+/browsers: URL.canParse\nif (path && !URL.canParse(path)) {\n  throw new Error(`connection path must be an absolute URL like 'http://host:8000', got: ${path}`);\n}\nconst client = new ChromaClient({ path });\n// better: avoid the deprecated path option entirely\nnew ChromaClient({ host: 'localhost', port: 8000, ssl: false });","typeGuard":"const isAbsoluteHttpUrl = (v: unknown): v is string =>\n  typeof v === 'string' && /^https?:\\/\\/.+/.test(v);","tryCatchPattern":"try {\n  client = new ChromaClient({ path });\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Invalid URL:')) {\n    client = new ChromaClient({ path: `http://${path}` }); // add the missing scheme and retry\n  } else throw e;\n}","preventionTips":["Prefer the host/port/ssl options; `path` is deprecated","Always include the http:// or https:// scheme in connection strings","Validate env-provided URLs with URL.canParse before constructing the client"],"tags":["javascript","url","connection","validation","deprecated-api"],"backgroundTag":"invalid-url","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}