Skip to content

fix: DSL translation crashes on missing litellm instead of degrading - #15

Merged
vicentebolea merged 1 commit into
masterfrom
fix/dsl-translate-graceful-degrade
Aug 13, 2026
Merged

fix: DSL translation crashes on missing litellm instead of degrading#15
vicentebolea merged 1 commit into
masterfrom
fix/dsl-translate-graceful-degrade

Conversation

@vicentebolea

Copy link
Copy Markdown
Member

Summary

  • Deployed vtk-mcp crashed on translate_prompt_to_dsl: ModuleNotFoundError: No module named 'litellm'.
  • Root cause: neither Dockerfile nor deploy.Dockerfile installed the vtk-validate[translate] extra (only plain vtk-validate), so litellm was never present in the image, even though translate_prompt_to_dsl is meant to work in production (it has a default model and dedicated VTK_MCP_TRANSLATE_* settings).
  • Separately, translate_prompt_to_dsl (src/vtk_mcp/tools/dsl.py) only wrapped from vtk_validate.dsl import translate_to_dsl in try/except ImportError — but translate_to_dsl imports litellm lazily inside its own body, so the ImportError raised there was outside the guarded block and propagated uncaught through the MCP tool call.

Changes

  • Move the translate_to_dsl(...) call inside the existing try/except ImportError so a missing litellm (or any other missing optional dep) degrades to "Error: vtk-validate[translate] not installed — ..." instead of crashing the tool call.
  • Dockerfile / deploy.Dockerfile: install vtk-validate[translate] so the feature actually works once deployed.
  • Add a regression test (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 passed
  • pytest -m unit — 58 passed
  • ruff check / ruff format --check on changed files — clean

…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.
@vicentebolea
vicentebolea merged commit e95540e into master Aug 13, 2026
7 checks passed
@vicentebolea
vicentebolea deleted the fix/dsl-translate-graceful-degrade branch August 13, 2026 01:02
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.

1 participant