{"record":{"id":"d186eec01febb163","repo":"infiniflow/ragflow","slug":"codeexec-contract-must-contain-exactly-one-busines","errorCode":null,"errorMessage":"CodeExec contract must contain exactly one business output, got {len(business_outputs)}","messagePattern":"CodeExec contract must contain exactly one business output, got (.+?)","errorType":"validation","errorClass":"ContractError","httpStatus":null,"severity":"error","filePath":"agent/tools/code_exec.py","lineNumber":72,"sourceCode":"\ndef _validate_business_output_name(name: str) -> None:\n    if not name or not name.strip():\n        raise ContractError(\"CodeExec business output name must not be empty\")\n    if name in SYSTEM_OUTPUT_KEYS:\n        raise ContractError(f\"CodeExec reserved output name is not allowed: {name}\")\n    if \".\" in name:\n        raise ContractError(f\"CodeExec business output name must not contain '.': {name}\")\n\n\ndef select_business_output(outputs: Mapping[str, object]) -> tuple[str, object]:\n    if len(outputs) == 1:\n        only_name, only_meta = next(iter(outputs.items()))\n        _validate_business_output_name(only_name)\n        return only_name, only_meta\n\n    business_outputs = [(name, meta) for name, meta in outputs.items() if name not in SYSTEM_OUTPUT_KEYS]\n    if len(business_outputs) != 1:\n        raise ContractError(f\"CodeExec contract must contain exactly one business output, got {len(business_outputs)}\")\n    _validate_business_output_name(business_outputs[0][0])\n    return business_outputs[0]\n\n\ndef normalize_output_value(value):\n    if isinstance(value, (tuple, list)):\n        return [normalize_output_value(item) for item in value]\n    if isinstance(value, dict):\n        return {key: normalize_output_value(item) for key, item in value.items()}\n    return value\n\n\ndef infer_actual_type(value) -> str:\n    value = normalize_output_value(value)\n    if value is None:\n        return \"Null\"\n    if isinstance(value, bool):\n        return \"Boolean\"","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/tools/code_exec.py#L54-L90","documentation":"Error \"CodeExec contract must contain exactly one business output, got {len(business_outputs)}\" thrown in infiniflow/ragflow.","triggerScenarios":"Thrown at agent/tools/code_exec.py:72 when the library encounters an invalid state.","commonSituations":"A CodeExec contract declares zero or multiple business outputs; reducing the contract to a single output prevents this error.","solutions":["Define exactly one business output in the CodeExec contract.","Merge multiple outputs into a single object output if several values are needed."],"exampleFix":"outputs = [{'name': 'result', 'type': 'Object'}]  # exactly one","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}