You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(integration): yapper backend tries to connect to external service in test mode #319
During integration testing, when running tests in certain configurations, the yapper backend attempts to connect to external services instead of using the local test backend. This causes test failures with NetworkError exceptions.
Root Cause
The yapper initialization logic in campus/yapper/__init__.py has a specific code path for STORAGE_MODE="1" (test mode), but there may be edge cases where:
STORAGE_MODE environment variable is not set before yapper.init() is called
The campus.storage.testing.is_test_mode() check returns False when it shouldn't
The fallback logic attempts to use campus_python.Campus to connect to remote vault
Expected Behavior
When ENV="testing", yapper should:
Use SQLiteYapper backend with a local temp file
Never attempt to connect to external services (campus_python.Campus)
Retrieve YAPPERDB_URI from local auth_resources.vault
Actual Behavior
In some test configurations, yapper:
Attempts to create campus_python.Campus client
Tries to connect to remote vault service
Fails with NetworkError/connection timeout
Code Context
campus/yapper/__init__.py around lines 67-75:
# In test mode (STORAGE_MODE=1), use local auth resources directly# to avoid connecting to external servicesifstorage_mode=="1":
fromcampus.authimportresourcesasauth_resourcesyapper_vault=auth_resources.vault["yapper"]
yapperdb_uri=yapper_vault["YAPPERDB_URI"]
yapper=SQLiteYapper(db=yapperdb_uri, client_id=client_id, **kwargs)
yapper._init_db()
returnyapper
Potential Solutions
Add explicit test mode check: Check ENV=="testing" in addition to STORAGE_MODE
Ensure STORAGE_MODE is always set in test fixtures: Verify campus.storage.testing.configure_test_storage() is called before any yapper initialization
Add early validation in yapper.init(): Raise a clear error if running in test mode but STORAGE_MODE is not set
Add logging: Log which backend path is being taken for easier debugging
Test Case
deftest_yapper_uses_local_backend_in_test_mode():
"""Verify yapper uses SQLite backend in test mode."""fromcampus.commonimportenv# Ensure test mode is configuredimportcampus.storage.testingcampus.storage.testing.configure_test_storage()
assertenv.get("STORAGE_MODE") =="1"# This should not attempt any network connectionsyapper=create_yapper()
assertisinstance(yapper, SQLiteYapper)
Priority
Medium - Tests can be run with proper setup, but the failure mode is confusing and fragile.
changed the title [-]integration: yapper backend tries to connect to external service in test mode[/-][+]fix(integration): yapper backend tries to connect to external service in test mode[/+]on Oct 3, 2026
Triage note (bug sweep 2026-10-04): no reproduction found — the STORAGE_MODE=1 local path in campus/yapper/__init__.py exists and all suites are green. The issue describes speculative edge cases (unset env before init). Leaving open pending a concrete repro; if one turns up, the fix is likely a test-fixture ordering guarantee rather than yapper code.
Fixed by the phase-2 yapper rework (#981, merged as c6f034b): yapper.create() resolves its DB via the documented priority chain (explicit db_uri → provider → YAPPERDB_URI env → remote vault) and raises in test mode instead of reaching the network when no URI resolves — campus/yapper/init.py:88-89 ("STORAGE_MODE=1 (test mode) must not contact external services"). Guarded by tests/unit/yapper/test_factory.py subprocess tests asserting the resolution order and the no-campus.auth` property. Dev-verified with the campus.api deploy.
Activity
[-]integration: yapper backend tries to connect to external service in test mode[/-][+]fix(integration): yapper backend tries to connect to external service in test mode[/+]nycomp commentedon Oct 3, 2026
Triage note (bug sweep 2026-10-04): no reproduction found — the
STORAGE_MODE=1local path incampus/yapper/__init__.pyexists and all suites are green. The issue describes speculative edge cases (unset env before init). Leaving open pending a concrete repro; if one turns up, the fix is likely a test-fixture ordering guarantee rather than yapper code.nycomp commentedon Oct 28, 2026
Fixed by the phase-2 yapper rework (#981, merged as c6f034b):
yapper.create()resolves its DB via the documented priority chain (explicitdb_uri→ provider →YAPPERDB_URIenv → remote vault) and raises in test mode instead of reaching the network when no URI resolves —campus/yapper/init.py:88-89 ("STORAGE_MODE=1 (test mode) must not contact external services"). Guarded bytests/unit/yapper/test_factory.pysubprocess tests asserting the resolution order and the no-campus.auth` property. Dev-verified with the campus.api deploy.