AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Stale Xfail Markers In Langchain-Core Tests Cause XPASS And Mask Future Regressions

Two unit tests in langchain-core (test_convert_to_openai_function_nested_v2 and test_sync_in_sync_lambdas) are decorated with @pytest.mark.xfail even though the underlying issues have been fixed. Running pytest reports XPASS (unexpectedly passing) for both tests. The stale markers should be removed to ensure test suite reflects current expected behavior and future regressions are not silently swallowed as XFAIL.

mediumConfidence 95%PytestAffected V1.4.8

Origin Analysis

The xfail markers were added when the tests were known to fail due to incomplete support for Pydantic v2 nested models in convert_to_openai_function and incorrect handling of sync-in-sync lambda streaming events. Subsequent commits fixed the underlying bugs but the xfail decorators were not removed, leaving the markers stale and causing XPASS.
cd libs/core && uv run --group test pytest tests/unit_tests/utils/test_function_calling.py::test_convert_to_openai_function_nested_v2 tests/unit_tests/runnables/test_runnable_events_v1.py::test_sync_in_sync_lambdas -v

Fixing Code Block

python - <<'PY' from pathlib import Path targets = { "tests/unit_tests/utils/test_function_calling.py": "test_convert_to_openai_function_nested_v2", "tests/unit_tests/runnables/test_runnable_events_v1.py": "test_sync_in_sync_lambdas", } for file_path, test_name in targets.items(): p = Path(file_path) lines = p.read_text().splitlines() out = [] i = 0 while i < len(lines): line = lines[i] stripped = line.strip() if stripped.startswith("@pytest.mark.xfail") and i + 1 < len(lines) and f"def {test_name}" in lines[i + 1]: # Skip the stale xfail decorator immediately preceding the target test function. i += 1 continue out.append(line) i += 1 p.write_text("\n".join(out) + "\n") PY
The script removes only the @pytest.mark.xfail decorator lines that appear immediately before the two named test functions. This minimal change leaves test bodies untouched and allows pytest to treat these tests as normal passing tests. The targeted condition prevents accidental removal of other xfail markers in the same files.

Edge Case Audit

The script modifies test files in place. It assumes single-line xfail decorators and standard formatting. After applying, run the targeted pytest command to confirm no XPASS remains and that the tests still pass. Rollback: use `git checkout -- tests/unit_tests/utils/test_function_calling.py tests/unit_tests/runnables/test_runnable_events_v1.py` to restore original files. If a future change reintroduces a failure in these tests, it will now be reported as a normal failure (not XFAIL), which is desired to avoid masking regressions.

Ecosystem Topology