Skip to content

fix(core): surface embedder config errors instead of silent mock fallback (#826)#842

Open
jyotirmya17 wants to merge 1 commit into
repowise-dev:mainfrom
jyotirmya17:fix/issue-826-embedder-config
Open

fix(core): surface embedder config errors instead of silent mock fallback (#826)#842
jyotirmya17 wants to merge 1 commit into
repowise-dev:mainfrom
jyotirmya17:fix/issue-826-embedder-config

Conversation

@jyotirmya17

@jyotirmya17 jyotirmya17 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Hi @RaghavChamadiya — thanks for the detailed breakdown on #826, it made the fix straightforward to scope correctly. This follows the architecture you suggested to resolve the conflation issue without falling back to clamping.

Summary

  • Shared validation helper: Added parse_numeric_env() and a typed EmbedderConfigError in core/providers/embedding/base.py. Strictly validates numeric inputs (rejects NaN, Inf, and values <= 0), shared across both dimensions and timeout.
  • CLI no longer masks config errors: build_embedder() now raises EmbedderConfigError explicitly instead of silently falling back to MockEmbedder. This is intentional — a bad config should crash the CLI, not degrade quietly.
  • MCP degradation path unaffected, now more precise: _server.py's existing broad try...except Exception around embedder instantiation already catches this, so EmbedderConfigError bubbles into the degradation envelope naturally — _embedder_status["reason"] now reports the exact config error instead of a generic failure.
  • Constructors kept in sync: Both _embedder_kwargs() and OllamaEmbedder.__init__() now go through the shared validator, so validation logic isn't duplicated or drifting between the two.

Scope note: No changes to public constructor signatures — only internal validation logic. Existing valid configs are unaffected; only invalid ones (previously silently mocked) now fail loudly.

Related Issues

Resolves #826

Test Plan

  • pytest passes — added 4 unit tests covering EmbedderConfigError on NaN, Inf, zero, and negative inputs for both dimensions and timeout
  • ruff check . passes
  • All existing tests still pass, no regressions

Checklist

  • Follows project code style
  • Tests added for new functionality
  • Existing tests pass
  • Docs updated where relevant (n/a — no public API surface changed)

@repowise-bot

repowise-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

✅ Health: 7.6 (unchanged)

📋 At a glance
4 hotspots touched · 1 file with recent fix history.

Files & modules (2)
  • packages (2 files)
    • .../providers/embedders.py
    • .../embedding/ollama.py
  • tests (2 files)
    • .../cli/test_shared_helpers.py
    • .../test_persistence/test_ollama_embedder.py

🩹 Review priority (files here with the most recent bug-fix history — defects cluster, so review these first)

🔎 More signals (1)

🔥 Hotspots touched (4)

  • .../providers/embedders.py — 4 commits/90d, 6 dependents · primary owner: biggiesmallcap-blip (40%)
  • .../cli/test_shared_helpers.py — 3 commits/90d, 0 dependents · primary owner: Swati Ahuja (82%)
  • .../embedding/ollama.py — 2 commits/90d, 5 dependents · primary owner: biggiesmallcap-blip (89%)
1 more
  • .../test_persistence/test_ollama_embedder.py — 2 commits/90d, 0 dependents · primary owner: biggiesmallcap-blip (79%)

👀 Suggested reviewers @biggiesmallcap-blip


📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-15 05:58 UTC
Silence on a single PR with [skip repowise] in the title · Per-repo toggle on repowise.dev/settings?tab=bot

@RaghavChamadiya

Copy link
Copy Markdown
Member

Thanks for turning this around quickly. The shared helper and typed error are the right shape, and I'm glad you raised rather than clamped.

One blocking item, on point 2 from my issue comment.

The config error is still swallowed on the search path. build_embedder's fallback wasn't the only swallow; the call sites have their own. search_cmd.py:166 and :286 wrap it in try: ... except Exception: pass and fall through to FTS, and update_cmd/incremental.py:31 does except Exception: return None. Against this branch:

OLLAMA_EMBEDDING_TIMEOUT=abc, repowise search
build_embedder RAISED: EmbedderConfigError -> Invalid OLLAMA_EMBEDDING_TIMEOUT: 'abc'
search_cmd guard: except Exception: pass
=> swallowed, silent fallthrough to FTS

So the reported symptom is unchanged; the swallow moved up a level. This is what the _embedder_status suggestion was reaching for: an envelope reports the error even with a broad except between the raise and the user. Raising alone can't survive those call sites. Relatedly, reindex_cmd.py:63 calls it bare and now shows a raw traceback, bypassing the MockEmbedder check plus click.Abort() right below it, which is the pattern worth extending.

MCP gemini mapper still has the original bug. _server.py:68 has its own _embedder_kwargs doing int(dims) if dims else 768, untouched, so REPOWISE_EMBEDDING_DIMS=-5 reaches the constructor unvalidated. The Ollama half of the MCP claim is right; this second copy needs the validator too.

Smaller: the error names the wrong var when value is picked by truthiness but name by presence (OLLAMA_EMBEDDING_DIMS="" + REPOWISE_EMBEDDING_DIMS=-5 reports the former); OllamaEmbedder(timeout=-5) skips validation via the is not None branch; the except EmbedderConfigError: raise block is a no-op; B904 needs from None. And list_issues.py looks like a debug script committed by accident, please drop it.

Tests pass (36 green). The body mentions NaN/Inf/zero tests but the four cover "invalid" and "-5" only; the validator handles the rest correctly, so it's just a coverage gap.

Happy to look again once config errors thread through an envelope instead of raising into call sites that catch broad Exception.

@jyotirmya17

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review, Raghav! That makes complete sense, I completely missed that those upstream call sites had broad exception catchers swallowing the new typed error.

I'll refactor this to use the envelope pattern/status object so config errors can safely bubble past those try/except blocks and reach the user. I'll also update the MCP gemini mapper to use the validator, patch up the smaller logic bugs, drop the accidental list_issues.py script, and fill in the missing test coverage.

I'll get these changes done as soon as possible and push an update to the branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants