{"record":{"id":"7f7be50a2c3b0eda","repo":"infiniflow/ragflow","slug":"codeexec-contract-mismatch-at-path-or-value-e-7f7be5","errorCode":null,"errorMessage":"CodeExec contract mismatch at {path or 'value'}: expected type {etype}, got {actual_type}","messagePattern":"CodeExec contract mismatch at (.+?): expected type (.+?), got (.+?)","errorType":"validation","errorClass":"ContractError","httpStatus":null,"severity":"error","filePath":"agent/tools/code_exec.py","lineNumber":180,"sourceCode":"            _validate_expected_type(inner_type, item, child_path)\n        return\n\n    actual_type = infer_actual_type(value)\n    if etype == \"String\":\n        valid = isinstance(value, str)\n    elif etype == \"Number\":\n        valid = _is_number(value)\n    elif etype == \"Boolean\":\n        valid = isinstance(value, bool)\n    elif etype == \"Object\":\n        valid = isinstance(value, dict)\n    elif etype == \"Null\":\n        valid = value is None\n    else:\n        raise ContractError(f\"Unsupported expected type: {expected_type}\")\n\n    if not valid:\n        raise ContractError(f\"CodeExec contract mismatch at {path or 'value'}: expected type {etype}, got {actual_type}\")\n\n\ndef build_code_exec_contract(outputs: Mapping[str, object], raw_result) -> dict[str, object]:\n    business_name, business_meta = select_business_output(outputs)\n    expected_type = \"\"\n    if isinstance(business_meta, Mapping):\n        expected_type = str(business_meta.get(\"type\") or \"\")\n\n    normalized_value = normalize_output_value(raw_result)\n    _validate_top_level_value_domain(normalized_value)\n    _validate_expected_type(expected_type, normalized_value)\n\n    return {\n        \"business_output\": business_name,\n        \"value\": normalized_value,\n        \"actual_type\": infer_actual_type(normalized_value),\n        \"content\": render_canonical_content(normalized_value),\n    }","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/tools/code_exec.py#L162-L198","documentation":"Error \"CodeExec contract mismatch at {path or 'value'}: expected type {etype}, got {actual_type}\" thrown in infiniflow/ragflow.","triggerScenarios":"Thrown at agent/tools/code_exec.py:180 when the library encounters an invalid state.","commonSituations":"A nested field of the CodeExec result has a different type than the contract declares; coercing the value to the declared type prevents this error.","solutions":["Return a value matching the expected contract type at the reported path.","Cast or restructure the value before returning it."],"exampleFix":"result = {'count': int(count)}  # match declared Number type","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"}