{"record":{"id":"b8066c6342b20a47","repo":"OpenBMB/ChatDev","slug":"encoding-cannot-be-empty","errorCode":null,"errorMessage":"encoding cannot be empty","messagePattern":"encoding cannot be empty","errorType":"validation","errorClass":"ConfigError","httpStatus":null,"severity":"error","filePath":"entity/configs/node/python_runner.py","lineNumber":42,"sourceCode":"    interpreter: str = field(default_factory=_default_interpreter)\n    args: List[str] = field(default_factory=list)\n    env: Dict[str, str] = field(default_factory=dict)\n    timeout_seconds: int = 60\n    encoding: str = \"utf-8\"\n\n    @classmethod\n    def from_dict(cls, data: Mapping[str, Any], *, path: str) -> \"PythonRunnerConfig\":\n        mapping = require_mapping(data, path)\n        interpreter = optional_str(mapping, \"interpreter\", path) or _default_interpreter()\n        args_raw = mapping.get(\"args\")\n        args = [str(item) for item in ensure_list(args_raw)] if args_raw is not None else []\n        env = optional_dict(mapping, \"env\", path) or {}\n        timeout_value = mapping.get(\"timeout_seconds\", 60)\n        if not isinstance(timeout_value, int) or timeout_value <= 0:\n            raise ConfigError(\"timeout_seconds must be a positive integer\", f\"{path}.timeout_seconds\")\n        encoding = optional_str(mapping, \"encoding\", path) or \"utf-8\"\n        if not encoding:\n            raise ConfigError(\"encoding cannot be empty\", f\"{path}.encoding\")\n        return cls(\n            interpreter=interpreter,\n            args=args,\n            env={str(key): str(value) for key, value in env.items()},\n            timeout_seconds=timeout_value,\n            encoding=encoding,\n            path=path,\n        )\n\n    FIELD_SPECS = {\n        \"interpreter\": ConfigFieldSpec(\n            name=\"interpreter\",\n            display_name=\"Python Path\",\n            type_hint=\"str\",\n            required=False,\n            default=_default_interpreter(),\n            description=\"Python executable file path, defaults to current process interpreter\",\n            advance=True,","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/OpenBMB/ChatDev/blob/4fb2db0ea90375ce1059f44fe03ffbd191a7a169/entity/configs/node/python_runner.py#L24-L60","documentation":"PythonRunnerConfig.from_dict defaults encoding to 'utf-8'; if an explicit 'encoding' value normalizes to an empty string (e.g. encoding: '' or whitespace-only), this ConfigError is raised at '<path>.encoding'.","triggerScenarios":"Setting encoding: \"\" or a whitespace-only string in the python_runner config.","commonSituations":"Template-generated configs leaving encoding empty; env var interpolation producing an empty string; a linter stripping the value.","solutions":["Remove the empty encoding key to use the utf-8 default","Set a valid codec name such as utf-8 or gbk","Strip/skip empty env-derived values before building config"],"exampleFix":"# before\nencoding: ''\n# after\nencoding: utf-8","handlingStrategy":"validation","validationCode":"enc = cfg.get('encoding') or 'utf-8'\nassert enc.strip(), 'encoding must be non-empty'","typeGuard":null,"tryCatchPattern":"try:\n    PythonRunnerConfig.from_dict(d, path='config')\nexcept ConfigError as e:\n    if 'encoding' in str(e):\n        d.pop('encoding', None)  # fall back to utf-8 default\n        PythonRunnerConfig.from_dict(d, path='config')","preventionTips":["Drop empty encoding keys when generating configs","Default env-derived encoding to utf-8"],"tags":["config","python-runner","encoding","validation"],"backgroundTag":"empty-config-value","analyzedSha":"4fb2db0ea90375ce1059f44fe03ffbd191a7a169","analyzedAt":"2026-08-27T14:35:29.622Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}