fix(rag): scope lazy-load catches so model failures aren't mislabeled 'not installed' (#118)#124
Open
daviddgonzalez wants to merge 1 commit into
Open
fix(rag): scope lazy-load catches so model failures aren't mislabeled 'not installed' (#118)#124daviddgonzalez wants to merge 1 commit into
daviddgonzalez wants to merge 1 commit into
Conversation
… 'not installed' loadPipeline in transformers-embedding-provider.ts wrapped both the dynamic import and the model download/inference in one catch that always rethrew '@xenova/transformers is not installed', swallowing the real error. Split the two failure modes: import failure keeps the install hint (now with cause), model/inference failure throws 'Failed to load transformers model' with cause. Audited onnx-embedding-provider.ts: its install-hint catch was already scoped to the import alone, but loadModel's download + session creation bubbled raw errors with no model context, so they now wrap with 'Failed to download/load ONNX model' preserving cause. Closes #118
|
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #124 +/- ##
==========================================
- Coverage 81.78% 81.69% -0.10%
==========================================
Files 223 223
Lines 17135 17155 +20
Branches 3326 3326
==========================================
Hits 14014 14014
- Misses 3121 3141 +20
🚀 New features to boost your workflow:
|
Collaborator
Author
|
This is just to do with I/O which will be tested in integration tests. Putting it in unit tests is redundant/might confuse other claudes that looks at the test suite |
Owner
|
@daviddgonzalez you can merge this whenever you are ready |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Closes #118.
Problem
loadPipelineinpackages/rag/src/embedding-providers/transformers-embedding-provider.tswrapped both the dynamicimport('@xenova/transformers')and the model download/inference in a singletry/catchthat always rethrew a fixed@xenova/transformers is not installedmessage. Any failure in step B (model download, network error,onnxruntime-nodenative backend, OOM, …) was reported as "not installed" even when the package was installed and importable — and the real error was swallowed, not even attached ascause.This actively misled debugging: a Windows CI failure was initially diagnosed as a missing/optional dependency when the package was in fact installed; the real failure was the model download / native backend. PR #119 fixed the test-reliability symptom by skipping those tests on Windows, but the misleading error remained.
Fix
transformers-embedding-provider.ts— split the two failure modes so each surfaces an accurate message:@xenova/transformers is not installedhint, now with the original error attached ascause(previously dropped entirely).Failed to load transformers model '<model>'preserving the original error ascause.A type-only import of
pipelinetypes the holder variable across the twotryblocks without animport()type annotation (lint) or any runtime dependency on the optional package.onnx-embedding-provider.ts(the issue's "audit siblings" note) — its install-hintcatch(loadOnnxRuntime) was already correctly scoped to the import alone, so it was left unchanged. ButloadModel's model download (ensureModelFiles) and session creation (InferenceSession.create) previously bubbled raw errors with no provider/model context, so they now throwFailed to download ONNX model '<model>'/Failed to load ONNX model '<model>'withcausepreserved.Tests
No new tests. This is a pure error-message refinement adding no new branches that aren't already exercised by the existing integration paths; the happy path stays covered by the integration tests. Full
bun run validate(lint, typecheck, unit + integration + system tests, duplication) passes.Changelog
Added an entry under
### Fixedin the[Unreleased]section.