diegosouzapw/OmniRoute · error · WebSearchExecutionError

Query must be 500 characters or fewer

Error message

Query must be 500 characters or fewer

What it means

Input validation failure in assertValidSearchInput(): the trimmed search query exceeds the 500-character limit enforced before dispatching to any provider. Thrown as WebSearchExecutionError with HTTP 400.

Solutions

  1. Shorten the query to 500 characters or fewer after trimming.
  2. Split very long searches into multiple targeted queries.
  3. Have the caller pre-truncate the query instead of sending oversized input.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/lib/search/executeWebSearch.ts:111 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/2d9c5f8faa826f15. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/search/executeWebSearch.ts:111

    typeof input.limit === "number"
      ? input.limit
      : typeof input.limit === "string"
        ? Number(input.limit)
        : Number.NaN;
  const requested = Number.isFinite(fromMaxResults)
    ? fromMaxResults
    : Number.isFinite(fromLimit)
      ? fromLimit
      : providerConfig.defaultMaxResults;
  return Math.min(Math.max(1, requested), providerConfig.maxMaxResults);
}

function assertValidSearchInput(input: ExecuteWebSearchInput) {
  if (typeof input.query !== "string" || input.query.trim().length === 0) {
    throw new WebSearchExecutionError("Missing required field: query", 400);
  }
  if (input.query.trim().length > 500) {
    throw new WebSearchExecutionError("Query must be 500 characters or fewer", 400);
  }
  if (
    input.search_type &&
    input.search_type !== "web" &&
    input.search_type !== "news" &&
    input.search_type !== "x"
  ) {
    throw new WebSearchExecutionError(`Unsupported search_type: ${String(input.search_type)}`, 400);
  }
}

export async function executeWebSearch(
  input: ExecuteWebSearchInput
): Promise<ExecuteWebSearchResult> {
  assertValidSearchInput(input);

  const log = input.log || defaultLog;
  if (input.provider === "x_search") input.provider = "x-search";

View on GitHub (pinned to a179ffed5b)