{"record":{"id":"f776224ea9b67e5c","repo":"FoundationAgents/MetaGPT","slug":"only-support-for-language-python-markdown-but-g","errorCode":null,"errorMessage":"Only support for language: python, markdown, but got {language}, ","messagePattern":"Only support for language: python, markdown, but got (.+?), ","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"metagpt/actions/di/execute_nb_code.py","lineNumber":276,"sourceCode":"                await self.build()\n\n                # run code\n                cell_index = len(self.nb.cells) - 1\n                success, outputs = await self.run_cell(self.nb.cells[-1], cell_index)\n\n                if \"!pip\" in code:\n                    success = False\n                    outputs = outputs[-INSTALL_KEEPLEN:]\n                elif \"git clone\" in code:\n                    outputs = outputs[:INSTALL_KEEPLEN] + \"...\" + outputs[-INSTALL_KEEPLEN:]\n\n            elif language == \"markdown\":\n                # add markdown content to markdown cell in a notebook.\n                self.add_markdown_cell(code)\n                # return True, beacuse there is no execution failure for markdown cell.\n                outputs, success = code, True\n            else:\n                raise ValueError(f\"Only support for language: python, markdown, but got {language}, \")\n\n            file_path = self.config.workspace.path / \"code.ipynb\"\n            nbformat.write(self.nb, file_path)\n            await self.reporter.async_report(file_path, \"path\")\n\n            return outputs, success\n\n\ndef remove_log_and_warning_lines(input_str: str) -> str:\n    delete_lines = [\"[warning]\", \"warning:\", \"[cv]\", \"[info]\"]\n    result = \"\\n\".join(\n        [line for line in input_str.split(\"\\n\") if not any(dl in line.lower() for dl in delete_lines)]\n    ).strip()\n    return result\n\n\ndef remove_escape_and_color_codes(input_str: str):\n    # 使用正则表达式去除jupyter notebook输出结果中的转义字符和颜色代码","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/actions/di/execute_nb_code.py#L258-L294","documentation":"ExecuteNBCode.run() executes code in a Jupyter notebook cell and dispatches on language: 'python' goes to the kernel, 'markdown' is appended as a markdown cell. Any other language string hits the terminal else branch and raises ValueError. This occurs during DataInterpreter code-execution rounds, typically after the LLM produced code tagged with a language the executor cannot run.","triggerScenarios":"await nb.run(code, language='html') or any value besides 'python'/'markdown'. Happens when the LLM labels a code block as 'bash'/'shell'/'json' and the parsing layer forwards that label to run(), or when custom tool code calls run() with an arbitrary language.","commonSituations":"LLM returns fenced code blocks with unusual info strings; user prompts the DataInterpreter to run shell commands which the LLM emits as ```bash blocks; prompt templates that let the model choose the language freely.","solutions":["Constrain the prompt to instruct the LLM to emit only python or markdown code blocks.","Normalize the parsed language label to 'python' when it is not 'markdown' before calling run().","Pre-check the language and skip/handle non-executable blocks (e.g. treat them as markdown output) instead of calling run()."],"exampleFix":"# before\noutputs, success = await nb.run(code, language=detected_language)  # may be 'bash'\n\n# after\nlanguage = 'markdown' if detected_language == 'markdown' else 'python'\noutputs, success = await nb.run(code, language=language)","handlingStrategy":"validation","validationCode":"language = 'markdown' if detected_language == 'markdown' else 'python'\noutputs, success = await nb.run(code, language=language)","typeGuard":"def is_runnable_language(lang: str) -> bool:\n    return lang in ('python', 'markdown')","tryCatchPattern":"try:\n    outputs, success = await nb.run(code, language=lang)\nexcept ValueError:\n    outputs, success = await nb.run(code, language='python')  # sanitize and retry","preventionTips":["Instruct the model to emit only ```python or ```markdown blocks.","Normalize parsed language labels before calling run().","Treat non-code blocks (json/html output) as markdown, never as executable."],"tags":["notebook","data-interpreter","llm-output","validation"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}