{"record":{"id":"1cc1429694298e19","repo":"Mintplex-Labs/anything-llm","slug":"res-reason-1cc142","errorCode":null,"errorMessage":"res.reason","messagePattern":"res\\.reason","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"frontend/src/models/dataConnector.js","lineNumber":36,"sourceCode":"        })\n        .then((data) => {\n          return { branches: data?.branches || [], error: null };\n        })\n        .catch((e) => {\n          console.error(e);\n          showToast(e.message, \"error\");\n          return { branches: [], error: e.message };\n        });\n    },\n    collect: async function ({ repo, accessToken, branch, ignorePaths = [] }) {\n      return await fetch(`${API_BASE}/ext/github/repo`, {\n        method: \"POST\",\n        headers: baseHeaders(),\n        body: JSON.stringify({ repo, accessToken, branch, ignorePaths }),\n      })\n        .then((res) => res.json())\n        .then((res) => {\n          if (!res.success) throw new Error(res.reason);\n          return { data: res.data, error: null };\n        })\n        .catch((e) => {\n          console.error(e);\n          return { data: null, error: e.message };\n        });\n    },\n  },\n  gitea: {\n    branches: async ({ repo, accessToken }) => {\n      return await fetch(`${API_BASE}/ext/gitea/branches`, {\n        method: \"POST\",\n        headers: baseHeaders(),\n        cache: \"force-cache\",\n        body: JSON.stringify({ repo, accessToken }),\n      })\n        .then((res) => res.json())\n        .then((res) => {","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/frontend/src/models/dataConnector.js#L18-L54","documentation":"Thrown by DataConnector.github.collect when the backend proxy at /ext/github/repo returns JSON with success:false. The thrown message is the backend's res.reason, surfaced to the caller as result.error after the .catch. This call walks repo contents on a branch honoring ignorePaths, so failures tend to originate from branch access or traversal rather than auth alone.","triggerScenarios":"Branch does not exist or has no commits; token lacks 'contents: read'; repo is empty; ignorePaths globs are malformed and break server-side filtering; repo is too large and the backend traversal times out.","commonSituations":"Default branch renamed from 'main' but caller still sends 'master'; monorepo traversal exceeds backend limits; ignorePaths sent as a string instead of an array; token scoped to a fork that lacks the requested branch.","solutions":["Confirm the branch name exists via the branches() call before collecting.","Pass ignorePaths as an array of glob strings to skip huge directories.","Verify 'contents: read' scope on the token.","If the repo is very large, narrow the collect with deeper ignorePaths or shard by directory."],"exampleFix":"// before\nconst { data } = await DataConnector.github.collect({ repo, accessToken, branch });\n\n// after\nconst { data, error } = await DataConnector.github.collect({\n  repo, accessToken, branch: branch || 'main', ignorePaths: ['node_modules/**','*.lock'],\n});\nif (error) { showToast(`GitHub collect: ${error}`, 'error'); return; }","handlingStrategy":"validation","validationCode":"function validateCollectArgs({ repo, accessToken, branch, ignorePaths }) {\n  if (!/^[-.\\w]+\\/[-.\\w]+$/.test(repo ?? '')) return 'repo must be \"owner/name\"';\n  if (!branch?.trim()) return 'branch is required';\n  if (!Array.isArray(ignorePaths)) return 'ignorePaths must be an array';\n  return null;\n}","typeGuard":"/** @param {unknown} r */\nfunction isCollectResult(r) {\n  return typeof r === 'object' && r !== null\n    && (r.error === null || typeof r.error === 'string');\n}","tryCatchPattern":"const { data, error } = await DataConnector.github.collect({ repo, accessToken, branch, ignorePaths });\nif (error) { showToast(`GitHub collect: ${error}`, 'error'); return null; }\nreturn data;","preventionTips":["Default branch to the result of branches() rather than hardcoding 'master'.","Always pass ignorePaths as an array, never a string.","Confirm branch existence before a full collect to fail fast.","Bound ignorePaths for huge repos to avoid backend timeouts."],"tags":["api","data-connector","github","auth","traversal"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}