Mintplex-Labs/anything-llm · error

Unsupported repo platform ${repo_platform}

Error message

Unsupported repo platform ${repo_platform}

What it means

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.

Source

Thrown at server/utils/middleware/isSupportedRepoProviders.js:8

// Middleware to validate that a repo provider URL is supported.
const REPO_PLATFORMS = ["github", "gitlab", "gitea"];

function isSupportedRepoProvider(request, response, next) {
  const { repo_platform = null } = request.params;
  if (!repo_platform || !REPO_PLATFORMS.includes(repo_platform))
    return response
      .status(500)
      .text(`Unsupported repo platform ${repo_platform}`);
  next();
}
module.exports = { isSupportedRepoProvider };

View on GitHub (pinned to 3aec848f28)

Solutions

  1. Use exactly one of github, gitlab, gitea (lowercase) in the URL path
  2. For gitlab/gitea, also supply the required body fields (access token, repo URL) so the forwarded collector call succeeds
  3. If you need a new provider: add it to REPO_PLATFORMS and implement the collector /ext/<platform>-repo endpoints
  4. 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

Example fix

// before
return response.status(500).text(`Unsupported repo platform ${repo_platform}`); // res.text is not an Express method

// after
return response.status(415).send(`Unsupported repo platform ${repo_platform}`);
Defensive patterns

Strategy: validation

Validate before calling

const REPO_PLATFORMS = ['github', 'gitlab', 'gitea'];
if (!REPO_PLATFORMS.includes(repo_platform))
  throw new Error(`repo_platform must be one of ${REPO_PLATFORMS.join('|')}`);
await post(`/ext/${repo_platform}/repo`, body);

Type guard

const isSupportedRepoPlatform = (p) =>
  typeof p === 'string' && ['github', 'gitlab', 'gitea'].includes(p.toLowerCase()) && p === p.toLowerCase();

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/b45b5e2b07c52b7e. Report an issue: GitHub.