Mintplex-Labs/anything-llm · warning · Error
res.reason
Error message
res.reason
What it means
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.
Source
Thrown at frontend/src/models/dataConnector.js:36
})
.then((data) => {
return { branches: data?.branches || [], error: null };
})
.catch((e) => {
console.error(e);
showToast(e.message, "error");
return { branches: [], error: e.message };
});
},
collect: async function ({ repo, accessToken, branch, ignorePaths = [] }) {
return await fetch(`${API_BASE}/ext/github/repo`, {
method: "POST",
headers: baseHeaders(),
body: JSON.stringify({ repo, accessToken, branch, ignorePaths }),
})
.then((res) => res.json())
.then((res) => {
if (!res.success) throw new Error(res.reason);
return { data: res.data, error: null };
})
.catch((e) => {
console.error(e);
return { data: null, error: e.message };
});
},
},
gitea: {
branches: async ({ repo, accessToken }) => {
return await fetch(`${API_BASE}/ext/gitea/branches`, {
method: "POST",
headers: baseHeaders(),
cache: "force-cache",
body: JSON.stringify({ repo, accessToken }),
})
.then((res) => res.json())
.then((res) => {View on GitHub (pinned to 526360e320)
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.
Example fix
// before
const { data } = await DataConnector.github.collect({ repo, accessToken, branch });
// after
const { data, error } = await DataConnector.github.collect({
repo, accessToken, branch: branch || 'main', ignorePaths: ['node_modules/**','*.lock'],
});
if (error) { showToast(`GitHub collect: ${error}`, 'error'); return; } Defensive patterns
Strategy: validation
Validate before calling
function validateCollectArgs({ repo, accessToken, branch, ignorePaths }) {
if (!/^[-.\w]+\/[-.\w]+$/.test(repo ?? '')) return 'repo must be "owner/name"';
if (!branch?.trim()) return 'branch is required';
if (!Array.isArray(ignorePaths)) return 'ignorePaths must be an array';
return null;
} Type guard
/** @param {unknown} r */
function isCollectResult(r) {
return typeof r === 'object' && r !== null
&& (r.error === null || typeof r.error === 'string');
} Try / catch
const { data, error } = await DataConnector.github.collect({ repo, accessToken, branch, ignorePaths });
if (error) { showToast(`GitHub collect: ${error}`, 'error'); return null; }
return data; Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- ${res.reason}
- Failed to sync GitHub file content. ${reason}
- ${response.error || "Failed to create slash command"}
- res.statusText
- Type "${type}" is not a valid type to sync.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/1cc1429694298e19.
Report an issue: GitHub.