Skip to content

fix: mock vision client in exc_info test to fix CI failure#804

Closed
teyrebaz33 wants to merge 3 commits into
NousResearch:mainfrom
teyrebaz33:fix/vision-tool-exc-info-caplog-2
Closed

fix: mock vision client in exc_info test to fix CI failure#804
teyrebaz33 wants to merge 3 commits into
NousResearch:mainfrom
teyrebaz33:fix/vision-tool-exc-info-caplog-2

Conversation

@teyrebaz33

@teyrebaz33 teyrebaz33 commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

Problem

test_analysis_error_logs_exc_info was failing in CI with:
assert mock_error.called
AssertionError: assert False

Root Cause

In CI environments where no vision API key is configured, _aux_async_client is None and DEFAULT_VISION_MODEL is None. The function returns early before reaching the download/error path, so logger.error is never called and the assertion fails.

Fix

Mock _aux_async_client and DEFAULT_VISION_MODEL in the test so the function proceeds past the early-return guard and actually reaches the error handling path.

Testing

All 42 vision tool tests pass locally.

Move caplog.at_level context manager before await calls and call
caplog.handler.setLevel() explicitly so log records with exc_info
are captured correctly in async tests on Python 3.11.

The previous test structure had caplog.at_level wrapping an await
expression, which caused exc_info to not be captured on Python 3.11
due to differences in async logging propagation between 3.11 and 3.12.
…1 compat

caplog does not reliably capture log records in async tests on Python 3.11.
Replace caplog with patch.object on the module logger and assert exc_info=True
was passed directly to the error call.
Without these mocks the function returns early when no vision client is
configured (CI environment), so logger.error is never called and the
assertion fails.
@teyrebaz33 teyrebaz33 changed the title fix: ensure exc_info captured in async caplog for Python 3.11 compat fix: mock vision client in exc_info test to fix CI failure Mar 10, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for identifying this CI issue! However, this fix is already on main — commit 0229e6b applied the same fix (mocking _aux_async_client and DEFAULT_VISION_MODEL), and commit 184aa5b further tightened the exc_info assertion. PR #803 (same fix by OutThisLife) was also already closed.

Appreciate you taking the time to dig into the root cause though — your analysis of the early-return guard was spot on. 🙏

@teknium1 teknium1 closed this Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants