{"record":{"id":"36e709cadff8752f","repo":"Mintplex-Labs/anything-llm","slug":"http-res-status-res-statustext","errorCode":null,"errorMessage":"HTTP ${res.status}: ${res.statusText}","messagePattern":"HTTP (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":200,"severity":"error","filePath":"collector/utils/downloadURIToFile/index.js","lineNumber":46,"sourceCode":" * @returns {Promise<{success: boolean, fileLocation: string|null, reason: string|null}>} - The path to the downloaded file\n */\nasync function downloadURIToFile(url, maxTimeout = 10_000) {\n  if (!url || typeof url !== \"string\" || !validURL(url))\n    return { success: false, reason: \"Not a valid URL.\", fileLocation: null };\n\n  try {\n    const abortController = new AbortController();\n    const timeout = setTimeout(() => {\n      abortController.abort();\n      console.error(\n        `Timeout ${maxTimeout}ms reached while downloading file for URL:`,\n        url.toString()\n      );\n    }, maxTimeout);\n\n    const res = await fetch(url, { signal: abortController.signal })\n      .then((res) => {\n        if (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`);\n        return res;\n      })\n      .finally(() => clearTimeout(timeout));\n\n    const urlObj = new URL(url);\n    const sluggedPath = slugify(urlObj.pathname, { lower: true });\n    let filename = `${urlObj.hostname}-${sluggedPath}`;\n\n    const existingExt = path.extname(filename).toLowerCase();\n    const { SUPPORTED_FILETYPE_CONVERTERS } = require(\"../constants\");\n\n    // If the filename does not already have a supported file extension,\n    // try to infer one from the response Content-Type header.\n    // This handles URLs like https://arxiv.org/pdf/2307.10265 where the\n    // path has no explicit extension but the server responds with\n    // Content-Type: application/pdf.\n    if (!SUPPORTED_FILETYPE_CONVERTERS.hasOwnProperty(existingExt)) {\n      const { parseContentType } = require(\"../../processLink/helpers\");","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/collector/utils/downloadURIToFile/index.js#L28-L64","documentation":"QDrant.namespaceExists(client, namespace) throws on a falsy namespace instead of returning false. This is asymmetric with its public wrapper hasNamespace(), which returns false for falsy input without throwing. The throw therefore signals a programming error at the call site: an internal caller passed an empty/missing namespace where a boolean answer was expected.","triggerScenarios":"Direct calls like namespaceExists(client, null) or namespaceExists(client) (default null); performSimilaritySearch / namespace-stats paths only reach it after their own guards, so hitting this throw means custom code or a refactor bypassed validation; passing an empty-string slug produced by a bad slugify.","commonSituations":"Custom integrations calling provider internals; code that assumed namespaceExists tolerates null like hasNamespace does; upstream refactors that reordered arguments.","solutions":["Use hasNamespace(namespace) for user-supplied or possibly-empty values — it returns a boolean and never throws for falsy input.","When calling namespaceExists directly, validate first: typeof namespace === 'string' && namespace.length > 0.","Trace the null back to its source (reqBody destructuring, slug generation) and fix it there.","Cover internal helpers with a unit test asserting the guard so signature drift is caught early."],"exampleFix":"// before\nconst exists = await qdrant.namespaceExists(client, maybeNull);\n\n// after\nconst exists = maybeNull && (await qdrant.hasNamespace(maybeNull));\n// or, if you must call the internal helper:\nif (!namespace) throw new Error('namespace required before existence check');\nconst exists = await qdrant.namespaceExists(client, namespace);","handlingStrategy":"type-guard","validationCode":"const isNonEmpty = (ns) => typeof ns === 'string' && ns.trim().length > 0;\nif (!isNonEmpty(namespace)) {\n  return false; // same semantics as hasNamespace: falsy namespace means 'no'\n}\nconst exists = await qdrant.namespaceExists(client, namespace);","typeGuard":"async function collectionExists(qdrantDB, client, namespace) {\n  if (typeof namespace !== 'string' || namespace.length === 0) return false; // never call namespaceExists with falsy\n  return await qdrantDB.namespaceExists(client, namespace);\n}","tryCatchPattern":"try {\n  const exists = await qdrant.namespaceExists(client, namespace);\n} catch (e) {\n  if (/No namespace value provided/.test(e.message)) {\n    // contract violation upstream: normalize instead of throwing where a boolean was expected\n    return false;\n  }\n  throw e;\n}","preventionTips":["Remember the asymmetry: hasNamespace(null) returns false; namespaceExists(client, null) throws — prefer the public wrapper.","Type-check the namespace before every namespaceExists call.","Trace falsy values to their source (destructuring defaults, slugify output) rather than catching downstream.","Add lint/test coverage on internal call sites that pass user input."],"tags":["qdrant","namespace","internal-api","type-guard","request-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}