{"record":{"id":"b45b5e2b07c52b7e","repo":"Mintplex-Labs/anything-llm","slug":"unsupported-repo-platform-repo-platform","errorCode":null,"errorMessage":"Unsupported repo platform ${repo_platform}","messagePattern":"Unsupported repo platform (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/utils/middleware/isSupportedRepoProviders.js","lineNumber":8,"sourceCode":"// Middleware to validate that a repo provider URL is supported.\nconst REPO_PLATFORMS = [\"github\", \"gitlab\", \"gitea\"];\n\nfunction isSupportedRepoProvider(request, response, next) {\n  const { repo_platform = null } = request.params;\n  if (!repo_platform || !REPO_PLATFORMS.includes(repo_platform))\n    return response\n      .status(500)\n      .text(`Unsupported repo platform ${repo_platform}`);\n  next();\n}\nmodule.exports = { isSupportedRepoProvider };\n","sourceCodeStart":1,"sourceCodeEnd":13,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/middleware/isSupportedRepoProviders.js#L1-L13","documentation":"Route-parameter validation for the Git-repo extensions: POST /ext/:repo_platform/branches and /ext/:repo_platform/repo (admin/manager only) require repo_platform to be exactly 'github', 'gitlab', or 'gitea' (lowercase, case-sensitive), else the middleware intends to return HTTP 500 'Unsupported repo platform <value>'. Caveat grounded in this codebase: the middleware calls response.text(...), which is not a standard Express method and no prototype patch exists anywhere in the repo — as written the call itself throws, so Express's default error handler answers with a generic 500 instead of the intended message.","triggerScenarios":"Calling /ext/bitbucket/repo or /ext/azure-devops/repo; capitalized values like /ext/Github/branches; POSTing to /ext//repo with an empty platform segment; custom forks adding a provider without extending REPO_PLATFORMS in server/utils/middleware/isSupportedRepoProviders.js.","commonSituations":"Assuming Bitbucket/Azure DevOps support because the UI mentions Git; URL typos and case mismatches; contributors adding a collector-side provider but forgetting the middleware allowlist.","solutions":["Use exactly one of github, gitlab, gitea (lowercase) in the URL path","For gitlab/gitea, also supply the required body fields (access token, repo URL) so the forwarded collector call succeeds","If you need a new provider: add it to REPO_PLATFORMS and implement the collector /ext/<platform>-repo endpoints","If you maintain the server: replace response.text(...) with response.status(...).send(...) — res.text is not an Express API, so the crafted message never renders as coded"],"exampleFix":"// before\nreturn response.status(500).text(`Unsupported repo platform ${repo_platform}`); // res.text is not an Express method\n\n// after\nreturn response.status(415).send(`Unsupported repo platform ${repo_platform}`);","handlingStrategy":"validation","validationCode":"const REPO_PLATFORMS = ['github', 'gitlab', 'gitea'];\nif (!REPO_PLATFORMS.includes(repo_platform))\n  throw new Error(`repo_platform must be one of ${REPO_PLATFORMS.join('|')}`);\nawait post(`/ext/${repo_platform}/repo`, body);","typeGuard":"const isSupportedRepoPlatform = (p) =>\n  typeof p === 'string' && ['github', 'gitlab', 'gitea'].includes(p.toLowerCase()) && p === p.toLowerCase();","tryCatchPattern":null,"preventionTips":["Restrict the platform picker UI to the three supported values","Keep the client allowlist in sync with REPO_PLATFORMS when forking","Lowercase the path segment before composing the URL"],"tags":["express","route-param","github","gitlab","gitea","validation"],"backgroundTag":"invalid-route-parameter","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}