{"record":{"id":"7c6b7f6dae3eb2e2","repo":"langchain-ai/langchain","slug":"expected-package-version-to-be-lt-version-r","errorCode":null,"errorMessage":"Expected {package} version to be < {lt_version}. Received {imported_version}.","messagePattern":"Expected (.+?) version to be < (.+?)\\. Received (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/utils/utils.py","lineNumber":172,"sourceCode":"\n    Args:\n        package: The name of the package.\n        lt_version: The version must be less than this.\n        lte_version: The version must be less than or equal to this.\n        gt_version: The version must be greater than this.\n        gte_version: The version must be greater than or equal to this.\n\n\n    Raises:\n        ValueError: If the package version does not meet the requirements.\n    \"\"\"\n    imported_version = parse(version(package))\n    if lt_version is not None and imported_version >= parse(lt_version):\n        msg = (\n            f\"Expected {package} version to be < {lt_version}. Received \"\n            f\"{imported_version}.\"\n        )\n        raise ValueError(msg)\n    if lte_version is not None and imported_version > parse(lte_version):\n        msg = (\n            f\"Expected {package} version to be <= {lte_version}. Received \"\n            f\"{imported_version}.\"\n        )\n        raise ValueError(msg)\n    if gt_version is not None and imported_version <= parse(gt_version):\n        msg = (\n            f\"Expected {package} version to be > {gt_version}. Received \"\n            f\"{imported_version}.\"\n        )\n        raise ValueError(msg)\n    if gte_version is not None and imported_version < parse(gte_version):\n        msg = (\n            f\"Expected {package} version to be >= {gte_version}. Received \"\n            f\"{imported_version}.\"\n        )\n        raise ValueError(msg)","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/utils/utils.py#L154-L190","documentation":"Raised by `check_package_version` in `langchain_core.utils.utils` when a version ceiling is enforced: the installed `package` version is greater than or equal to `lt_version` and the caller required strictly less than that. Integrations use this guard to refuse running against a dependency major version whose API they no longer match. The message shows expected ceiling vs. actually imported version.","triggerScenarios":"A LangChain integration (or your own call to `check_package_version(pkg, lt_version=\"1.0\")`) executes after the environment was upgraded — e.g. `pydantic` 2.x installed where the code path requires `<2`, or a provider SDK bumped to a breaking major. Triggered at import/first use of the guarded integration.","commonSituations":"`pip install` of another package silently upgrading a shared dependency past a ceiling; stale LangChain integration against a newly released major SDK; environment drift between dev (pinned) and prod (loose) requirements; CI installing latest instead of locked versions.","solutions":["Pin the package below the ceiling in the message: e.g. `pip install \"pydantic<2\"` (or add the constraint to requirements/uv.lock).","Prefer upgrading the LangChain integration to a release that supports the new major version — usually better than downgrading.","Use a lockfile (uv.lock / requirements.txt with `==`) so transitive upgrades cannot break the ceiling silently."],"exampleFix":"# before\n# ValueError: Expected pydantic version to be < 2.0.0. Received 2.7.1.\n\n# after (terminal)\n# pip install \"pydantic<2\"\n# or upgrade the integration that enforces the ceiling:\n# pip install -U langchain-openai","handlingStrategy":"validation","validationCode":"from packaging.version import Version, InvalidVersion\n\ndef version_lt(pkg: str, ceiling: str) -> bool:\n    try:\n        return Version(importlib.metadata.version(pkg)) < Version(ceiling)\n    except (importlib.metadata.PackageNotFoundError, InvalidVersion):\n        return False\n\nif not version_lt(\"pydantic\", \"2\"):\n    raise RuntimeError(\"pin pydantic<2 or upgrade this integration\")","typeGuard":null,"tryCatchPattern":"try:\n    check_package_version(pkg, lt_version=ceiling)\nexcept ValueError as e:\n    # environment drift — pin or upgrade, do not silence\n    raise RuntimeError(f\"dependency ceiling violated: {e}\") from e","preventionTips":["Install from a lockfile (uv sync / pip install -r requirements.lock) in prod.","When upgrading a shared dependency major, upgrade the LangChain integration in the same change.","Add a startup version assertion so drift is caught at boot, mid-request."],"tags":["versioning","dependencies","environment"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}