Conversation
translate_file() forwarded per-job provider keys on the EPUB path only. The TXT/SRT adapter path's llm_config and the DOCX create_llm_provider call omitted nim_api_key, so with llm_provider='nim', a per-job NIM key and no NIM key in .env, the factory fell back to the empty env value: TXT/SRT jobs failed mid-run with 'NIM provider requires an API key' (the key silently dropped) and DOCX jobs raised at provider creation. Thread nim_api_key at both call sites, matching the EPUB path. The sibling per-job keys were audited and are already forwarded at both sites. Regression tests drive the real translate_file() entry point per format with the real factory; only the network boundary is stubbed.
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.
Problem
A NIM API key entered per job in the web UI only works for EPUB jobs. TXT, SRT and DOCX jobs silently drop it: with no NIM key in
.env, the provider factory falls back to the empty.envvalue and the job fails even though a valid key was provided (#230).Root cause
translate_file()forwards the per-job provider keys on the EPUB path only:llm_configwithoutnim_api_key(src/core/adapters/translate_file.py:335-344)create_llm_provider()without it (src/core/adapters/translate_file.py:263-273)The factory's
nimbranch (src/core/llm/factory.py:164-169) reads the kwarg before its env fallback, so the key never arrives and_require_keyraises "NVIDIA NIM provider requires an API key". For TXT/SRT this surfaces mid-run as a failed unit (the job endspartial); for DOCX it raises at provider creation.Fix
Thread
nim_api_keyat both call sites, matching the EPUB path. Two one-line kwargs; nothing else changes.I also audited the sibling per-job keys (
gemini,openai,openrouter,mistral,deepseek,poe) at both call sites, all are already forwarded; NIM was the only omission, at both sites.How to reproduce (before the fix)
nim, a per-job NIM API key filled in the web UI, and noNIM_API_KEYin.env.partial, the output file is untranslated. DOCX: the job errors immediately at provider creation.Testing
New
tests/unit/test_translate_file_per_job_keys.pydrives the realtranslate_file()entry point per format (txt, srt, docx) withllm_provider='nim', a per-job key andNIM_API_KEYabsent; the real factory runs (its_require_keygate is the oracle), only the network boundary (provider.generate) is stubbed. All four tests fail on the old code (TXT/SRT: job ends partial; DOCX: the exact factory ValueError) and pass with the fix.The single failure (
test_path_validator.py::test_reject_path_separator_backslash) also fails on the clean base commit0a26cec: it assumes\is a path separator, which it is not on macOS/Linux. Unrelated to this change.Changes
src/core/adapters/translate_file.py: addnim_api_keyto the DOCXcreate_llm_providercall and to the TXT/SRTllm_configtests/unit/test_translate_file_per_job_keys.py: regression tests (new file)Closes #230