musistudio/claude-code-router · error · Error

Model name is too long.

Error message

Model name is too long.

What it means

readDeepLinkModels collects model names from query params and payload, splits combined values, and enforces maxModelLength per individual model name. Any single model string longer than the cap throws 'Model name is too long.' before dedupe.

Source

Thrown at packages/core/src/contracts/deep-link.ts:513

  const protocol = value.trim();
  if (!providerProtocols.has(protocol as GatewayProviderProtocol)) {
    throw new Error(`Unsupported provider protocol: ${value}`);
  }
  return protocol as GatewayProviderProtocol;
}

function readDeepLinkModels(params: URLSearchParams, payload: Record<string, unknown> | undefined): string[] {
  const values = [
    ...params.getAll("models"),
    ...payloadModels(payload)
  ];
  const seen = new Set<string>();
  const models: string[] = [];

  for (const value of values) {
    for (const model of splitModelValue(value)) {
      if (model.length > maxModelLength) {
        throw new Error("Model name is too long.");
      }
      if (seen.has(model)) {
        continue;
      }
      seen.add(model);
      models.push(model);
      if (models.length > maxModels) {
        throw new Error("Too many models in provider link.");
      }
    }
  }

  return models;
}

function payloadModels(payload: Record<string, unknown> | undefined): string[] {
  if (!payload) {
    return [];

View on GitHub (pinned to 99f24806c6)

Solutions

  1. Use the expected delimiter (comma) so values split into individual short names
  2. Trim whitespace/URL artifacts from each model name
  3. Keep model identifiers to real provider model IDs (tens of chars), not descriptions

Example fix

// before
models=model-a%2Cmodel-b%2C...glued-long-string-without-delimiters
// after
models=model-a,model-b
Defensive patterns

Strategy: validation

Validate before calling

const names = rawModels.split(",").map(s => s.trim()).filter(Boolean); if (names.some(n => n.length > 200)) return trimModels();

Type guard

const allModelsWithinCap = (models: string[], cap = 200) => models.every(m => m.length <= cap);

Try / catch

try { parseProviderDeepLinkPayload(url); } catch (e) { if (e instanceof Error && e.message === "Model name is too long.") return splitAndSanitizeModels(url); throw e; }

Prevention

When it happens

Trigger: A models= or payload models entry containing a model identifier longer than maxModelLength — often because a whole comma list wasn't split on the expected delimiter, or a URL fragment got glued onto a model name.

Common situations: Passing an unsplit list 'model-a,model-b,...' when the delimiter differs (semicolon, newline); model values containing trailing URL params from bad encoding; copy-paste appending duplicated text.

Related errors


AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27). Data as JSON: /api/errors/7adf36c5d2f803d3. Report an issue: GitHub.