Skip to content

[Bug] OLLAMA_EMBEDDING_TIMEOUT is not validated; a malformed value silently downgrades to MockEmbedder #826

Description

@austintraver

Describe the Bug

The Ollama embed request timeout (added in #656) is read from OLLAMA_EMBEDDING_TIMEOUT / REPOWISE_EMBEDDING_TIMEOUT and passed straight through float(...) with no validation, in both the CLI mapper and the embedder constructor:

  • packages/cli/src/repowise/cli/providers/embedders.py_embedder_kwargs() does kwargs["timeout"] = float(timeout)
  • packages/core/src/repowise/core/providers/embedding/ollama.py__init__ does float(env_timeout) if env_timeout else _DEFAULT_TIMEOUT

Two failure modes result:

  1. A non-numeric value raises, and the CLI path swallows it into a silent MockEmbedder. OLLAMA_EMBEDDING_TIMEOUT=abc makes float("abc") raise ValueError inside _embedder_kwargs(). build_embedder() catches it with except Exception: return MockEmbedder(), so semantic search silently runs on mock vectors with no error. This is the same silent-degradation class as [Bug] Configured embedder silently falls back to MockEmbedder on init failure — broken semantic search looks healthy #306, which fix(mcp): surface embedder init failure instead of silent mock fallback #324 fixed for the MCP-server path (via the _embedder_status envelope); but the CLI build_embedder() path was not covered and still swallows to mock.

  2. Non-positive / non-finite values are accepted and passed to httpx. 0, -5, inf, nan all pass the bare float() and reach httpx.AsyncClient(timeout=...). A 0 or negative timeout makes every embed request fail immediately; inf/nan are nonsensical.

Steps to Reproduce

  1. Configure the Ollama embedder: export OLLAMA_EMBEDDING_MODEL=embeddinggemma
  2. Set a malformed timeout: export OLLAMA_EMBEDDING_TIMEOUT=abc (also try 0, -5, inf)
  3. Run any flow that builds the embedder, e.g. repowise reindex, or directly:
    from repowise.cli.providers import build_embedder
    build_embedder("ollama")   # with abc -> returns MockEmbedder() silently

Expected Behavior

A malformed, non-positive, or non-finite timeout is reported rather than silently swallowed, and the value is validated before use. Ideally consistent with the direction taken in #324 (surface the degradation, e.g. via _embedder_status, rather than silently mock). The exact shape is a maintainer call.

Actual Behavior

  • OLLAMA_EMBEDDING_TIMEOUT=abc -> build_embedder("ollama") returns MockEmbedder() with only a WARNING on the CLI path; semantic search silently disabled.
  • OLLAMA_EMBEDDING_TIMEOUT=0 / -5 / inf -> passed unvalidated to httpx.AsyncClient(timeout=...).

Environment

Additional Context

Related: #656 (added the configurable timeout), and #306 / #324 (the silent-MockEmbedder-on-init class, fixed for the MCP path only).

Happy to open a PR once the intended shape is decided, specifically whether a bad embedder config should surface through the _embedder_status degradation envelope (matching #324), warn, or clamp, and whether the CLI build_embedder() fallback should distinguish configuration errors from genuine provider-unavailability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions