{"record":{"id":"e25aa7faa89e48b9","repo":"langchain-ai/langchain","slug":"invalid-format-self-schema-format","errorCode":null,"errorMessage":"Invalid format: {self._schema_format}","messagePattern":"Invalid format: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/tracers/core.py","lineNumber":387,"sourceCode":"            extra=kwargs,\n            events=[{\"name\": \"start\", \"time\": start_time}],\n            start_time=start_time,\n            child_runs=[],\n            run_type=run_type or \"chain\",\n            name=name,\n            tags=tags or [],\n        )\n\n    def _get_chain_inputs(self, inputs: Any) -> Any:\n        \"\"\"Get the inputs for a chain run.\"\"\"\n        if self._schema_format in {\"original\", \"original+chat\"}:\n            return inputs if isinstance(inputs, dict) else {\"input\": inputs}\n        if self._schema_format == \"streaming_events\":\n            return {\n                \"input\": inputs,\n            }\n        msg = f\"Invalid format: {self._schema_format}\"\n        raise ValueError(msg)\n\n    def _get_chain_outputs(self, outputs: Any) -> Any:\n        \"\"\"Get the outputs for a chain run.\"\"\"\n        if self._schema_format in {\"original\", \"original+chat\"}:\n            return outputs if isinstance(outputs, dict) else {\"output\": outputs}\n        if self._schema_format == \"streaming_events\":\n            return {\n                \"output\": outputs,\n            }\n        msg = f\"Invalid format: {self._schema_format}\"\n        raise ValueError(msg)\n\n    def _complete_chain_run(\n        self,\n        outputs: dict[str, Any],\n        run_id: UUID,\n        inputs: dict[str, Any] | None = None,\n    ) -> Run:","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/tracers/core.py#L369-L405","documentation":"Raised by BaseLangChainTracer._get_chain_inputs when normalizing chain run inputs for a tracer whose _schema_format is not one of the supported values ('original', 'original+chat', 'streaming_events'). The tracer cannot decide whether to wrap non-dict inputs under an 'input' key or pass them through, so it refuses to record the run. It indicates a misconstructed or version-mismatched tracer rather than bad user data.","triggerScenarios":"Instantiating BaseLangChainTracer (or a subclass) and setting _schema_format to an arbitrary/custom string; passing a tracer built against a newer langchain-core (which introduced new formats) into an older runtime that does not recognize it; calling on_chain_start with such a tracer attached to config['callbacks'].","commonSituations":"Custom tracer subclasses that override __init__ and set _schema_format from a constructor kwarg without validating it; mixing langchain-core versions in one environment (e.g. a partner package pinning an older core); copy-pasted tracer code from a different core version.","solutions":["Do not set _schema_format yourself; use the default ('original') or the documented values 'original+chat' / 'streaming_events'","If subclassing, validate the value in __init__ against {'original','original+chat','streaming_events'} and raise early","Align versions: uv sync so every langchain-* package uses the same langchain-core version","If you need a custom input schema, override _get_chain_inputs/_get_chain_outputs entirely instead of inventing a format string"],"exampleFix":"// before\nclass MyTracer(BaseLangChainTracer):\n    def __init__(self):\n        self._schema_format = \"my_format\"\n// after\nclass MyTracer(BaseLangChainTracer):\n    def __init__(self):\n        self._schema_format = \"original\"  # or 'streaming_events'","handlingStrategy":"validation","validationCode":"VALID_FORMATS = {\"original\", \"original+chat\", \"streaming_events\"}\nassert tracer._schema_format in VALID_FORMATS, tracer._schema_format","typeGuard":"def is_valid_schema_format(fmt: str) -> bool:\n    return fmt in {\"original\", \"original+chat\", \"streaming_events\"}","tryCatchPattern":null,"preventionTips":["Never assign custom strings to _schema_format; treat it as an internal, closed enum","Validate tracer configuration in __init__ of subclasses, not mid-run","Keep one langchain-core version across the environment (uv sync)"],"tags":["tracing","langsmith","configuration","langchain-core"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}