diegosouzapw/OmniRoute · error · Error

Local corpus endLine must be greater than or equal to…

Error message

Local corpus endLine must be greater than or equal to startLine

What it means

After both line numbers were normalized to positive integers (startLine defaulting to 1, endLine defaulting to startLine + maxReadLines - 1), the effective requestedEnd is still smaller than requestedStart. This only happens when options explicitly pass an endLine smaller than startLine — an inverted line range in the read request.

Solutions

  1. Swap or fix the startLine/endLine values
  2. Default endLine to startLine + maxReadLines - 1 when omitted
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/lib/localCorpus/index.ts:587 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/1c6fb67c9ad9bfaf. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/localCorpus/index.ts:587

      throw new Error("Local corpus file path escapes the configured root");
    }

    let content: string;
    try {
      content = await fs.readFile(canonicalFile, "utf8");
    } catch {
      throw new Error("Local corpus file is not accessible");
    }
    if (content.includes("\0")) throw new Error("Local corpus file is not valid text");

    const lines = content.split(/\r?\n/);
    const requestedStart = positiveInteger(options.startLine, 1);
    const requestedEnd = positiveInteger(
      options.endLine,
      requestedStart + this.limits.maxReadLines - 1
    );
    if (requestedEnd < requestedStart) {
      throw new Error("Local corpus endLine must be greater than or equal to startLine");
    }

    const startLine = Math.min(requestedStart, Math.max(lines.length, 1));
    const endLine = Math.min(lines.length, requestedEnd, startLine + this.limits.maxReadLines - 1);
    return {
      relativePath: normalizeRelativePath(path.relative(root, canonicalFile)),
      content: lines.slice(startLine - 1, endLine).join("\n"),
      startLine,
      endLine,
      totalLines: lines.length,
      truncated: startLine > 1 || endLine < lines.length,
    };
  }
}

export function getDefaultLocalCorpusStatus(): LocalCorpusStatus {
  const limits = resolveLimits({});
  return {

View on GitHub (pinned to a179ffed5b)