infiniflow/ragflow · error · ContractError
CodeExec contract mismatch at {path or 'value'}: expected ty
Error message
CodeExec contract mismatch at {path or 'value'}: expected type {etype}, got {actual_type} What it means
Error "CodeExec contract mismatch at {path or 'value'}: expected type {etype}, got {actual_type}" thrown in infiniflow/ragflow.
Source
Thrown at agent/tools/code_exec.py:180
_validate_expected_type(inner_type, item, child_path)
return
actual_type = infer_actual_type(value)
if etype == "String":
valid = isinstance(value, str)
elif etype == "Number":
valid = _is_number(value)
elif etype == "Boolean":
valid = isinstance(value, bool)
elif etype == "Object":
valid = isinstance(value, dict)
elif etype == "Null":
valid = value is None
else:
raise ContractError(f"Unsupported expected type: {expected_type}")
if not valid:
raise ContractError(f"CodeExec contract mismatch at {path or 'value'}: expected type {etype}, got {actual_type}")
def build_code_exec_contract(outputs: Mapping[str, object], raw_result) -> dict[str, object]:
business_name, business_meta = select_business_output(outputs)
expected_type = ""
if isinstance(business_meta, Mapping):
expected_type = str(business_meta.get("type") or "")
normalized_value = normalize_output_value(raw_result)
_validate_top_level_value_domain(normalized_value)
_validate_expected_type(expected_type, normalized_value)
return {
"business_output": business_name,
"value": normalized_value,
"actual_type": infer_actual_type(normalized_value),
"content": render_canonical_content(normalized_value),
}View on GitHub (pinned to 554fb1133a)
Solutions
- Return a value matching the expected contract type at the reported path.
- Cast or restructure the value before returning it.
Example fix
result = {'count': int(count)} # match declared Number type When it happens
Trigger: Thrown at agent/tools/code_exec.py:180 when the library encounters an invalid state.
Common situations: 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.
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/7f7be50a2c3b0eda.
Report an issue: GitHub.