fix: DSL translation crashes on missing litellm instead of degrading - #15
Merged
Merged
Conversation
…tall vtk-validate[translate] translate_prompt_to_dsl only caught ImportError from importing vtk_validate.dsl itself, not from the call to translate_to_dsl(), which imports litellm lazily inside the function body. With litellm missing, that ImportError escaped uncaught through the MCP tool call. Neither Dockerfile installed the vtk-validate[translate] extra, so litellm was never present in a deployed image — this is the actual production trigger; the call-site fix is defense in depth so a missing optional dependency degrades to an error string instead of a crash.
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.
Summary
vtk-mcpcrashed ontranslate_prompt_to_dsl:ModuleNotFoundError: No module named 'litellm'.Dockerfilenordeploy.Dockerfileinstalled thevtk-validate[translate]extra (only plainvtk-validate), solitellmwas never present in the image, even thoughtranslate_prompt_to_dslis meant to work in production (it has a default model and dedicatedVTK_MCP_TRANSLATE_*settings).translate_prompt_to_dsl(src/vtk_mcp/tools/dsl.py) only wrappedfrom vtk_validate.dsl import translate_to_dslintry/except ImportError— buttranslate_to_dslimportslitellmlazily inside its own body, so theImportErrorraised there was outside the guarded block and propagated uncaught through the MCP tool call.Changes
translate_to_dsl(...)call inside the existingtry/except ImportErrorso a missinglitellm(or any other missing optional dep) degrades to"Error: vtk-validate[translate] not installed — ..."instead of crashing the tool call.Dockerfile/deploy.Dockerfile: installvtk-validate[translate]so the feature actually works once deployed.test_missing_litellm_returns_error) covering ImportError raised at call time, not just at import time.Test plan
pytest tests/test_dsl_tools.py -v— 9 passedpytest -m unit— 58 passedruff check/ruff format --checkon changed files — clean