Skip to content

regex search: | alternation silently returns 0 matches (false negatives) #628

@justrach

Description

@justrach

Summary

In search / faster_search with mode=regex (flavor zigrep_basic), the | alternation operator does not work and the search returns 0 matches silently — no error, no warning. This reads as a confident "pattern not found" when the terms are actually present, which is actively misleading and caused me to draw wrong conclusions while searching a codebase.

Reproduction

File index.ts line 1:

import { generateText, streamText, createGateway } from "ai";
pattern mode result expected
createGateway regex 2 matches ✓ 2
generateText|streamText regex 0 matches matches line 1
nonexistentword|createGateway regex 0 matches matches createGateway

The single-term regex finds it; the moment an alternation | is added, the whole query returns 0 — even though one of the alternatives clearly matches.

Impact

  • Silent false negatives. A multi-term a|b|c "does any of these exist" sweep — a very common first-pass search — returns 0 and looks authoritative.
  • No signal that alternation is unsupported. If zigrep_basic is intentionally POSIX BRE (where | is a literal char, alternation requires \|), that's a reasonable engine choice, but it's a footgun without feedback.

Suggested fix (any one)

  1. Support ERE-style | alternation in mode=regex, or
  2. If | is literal in BRE, detect a bare | in a regex pattern and surface a hint (e.g. "| is literal in basic regex; use \\| for alternation or split into multiple queries"), or
  3. At minimum, document the flavor's alternation semantics in the tool description.

Environment

  • codedbpro v0.2.9
  • Both search and faster_search regex modes affected (same backend).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions