{"record":{"id":"745e41ebf801efeb","repo":"langchain-ai/langchain","slug":"unsupported-version-version-r-expected-v1","errorCode":null,"errorMessage":"Unsupported version: {version!r}. Expected 'v1', 'v2', or 'v3'.","messagePattern":"Unsupported version: (.+?)\\. Expected 'v1', 'v2', or 'v3'\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/runnables/base.py","lineNumber":1655,"sourceCode":"                removal=\"2.0.0\",\n            )\n            # First implementation, built on top of astream_log API\n            # This implementation will be deprecated as of 0.2.0\n            event_stream = _astream_events_implementation_v1(\n                self,\n                input,\n                config=config,\n                include_names=include_names,\n                include_types=include_types,\n                include_tags=include_tags,\n                exclude_names=exclude_names,\n                exclude_types=exclude_types,\n                exclude_tags=exclude_tags,\n                **kwargs,\n            )\n        else:\n            msg = f\"Unsupported version: {version!r}. Expected 'v1', 'v2', or 'v3'.\"  # type: ignore[unreachable]\n            raise NotImplementedError(msg)\n\n        async with aclosing(event_stream):\n            async for event in event_stream:\n                yield event\n\n    @overload\n    def stream_events(\n        self,\n        input: Any,\n        config: RunnableConfig | None = None,\n        *,\n        version: Literal[\"v1\", \"v2\"] = \"v2\",\n        include_names: Sequence[str] | None = None,\n        include_types: Sequence[str] | None = None,\n        include_tags: Sequence[str] | None = None,\n        exclude_names: Sequence[str] | None = None,\n        exclude_types: Sequence[str] | None = None,\n        exclude_tags: Sequence[str] | None = None,","sourceCodeStart":1637,"sourceCodeEnd":1673,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/runnables/base.py#L1637-L1673","documentation":"Raised by `Runnable.astream_events` when the `version` argument is anything other than the literals 'v1', 'v2', or 'v3'. The dispatch chain matches those three strings and falls into an `else` branch marked `# type: ignore[unreachable]` (unreachable only from the type-checker's perspective — at runtime arbitrary strings reach it), raising `NotImplementedError` with the offending value echoed via `{version!r}`.","triggerScenarios":"`chain.astream_events(inp, version=\"v4\")`, `version=\"V2\"` (capitalized), `version=\"2\"` (missing the v), or a version string read from config without validation. The Literal type protects typed call sites only; untyped strings pass straight through.","commonSituations":"Version values sourced from environment variables, YAML config, or CLI flags; code written against future/imagined API versions; typos and casing mistakes that static typing does not catch because the call site is untyped.","solutions":["Use exactly `\"v1\"`, `\"v2\"`, or `\"v3\"` — current default is `\"v2\"`","If the version comes from config, validate it once at load: `if version not in {\"v1\",\"v2\",\"v3\"}: raise ConfigError(...)`","Omit the argument entirely when the default (v2) is acceptable"],"exampleFix":"# before\nversion = os.environ.get(\"EVENTS_VERSION\", \"2\")\nchain.astream_events(inp, version=version)  # NotImplementedError: Unsupported version: '2'\n\n# after\nversion = os.environ.get(\"EVENTS_VERSION\", \"v2\")\nassert version in {\"v1\", \"v2\", \"v3\"}\nchain.astream_events(inp, version=version)","handlingStrategy":"validation","validationCode":"EVENT_VERSIONS = {\"v1\", \"v2\", \"v3\"}\n\ndef checked_event_version(v: str) -> str:\n    if v not in EVENT_VERSIONS:\n        msg = f\"event version must be one of {sorted(EVENT_VERSIONS)}, got {v!r}\"\n        raise ValueError(msg)\n    return v","typeGuard":"def is_event_version(v: object) -> bool:\n    return isinstance(v, str) and v in {\"v1\", \"v2\", \"v3\"}","tryCatchPattern":"try:\n    async for ev in chain.astream_events(inp, version=v):\n        ...\nexcept NotImplementedError as e:\n    if \"Unsupported version\" in str(e):\n        raise ValueError(f\"bad event version from config: {v!r}\") from e\n    raise","preventionTips":["Type the parameter as Literal['v1','v2','v3'] at every API boundary","Validate config-sourced version strings at load time","Omit version to accept the supported default"],"tags":["runnables","streaming","astream-events","notimplementederror","input-validation"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}