fix(email): remove redundant env re-read in _connect_imap#378
Closed
robotlearning123 wants to merge 6 commits intomainfrom
Closed
fix(email): remove redundant env re-read in _connect_imap#378robotlearning123 wants to merge 6 commits intomainfrom
robotlearning123 wants to merge 6 commits intomainfrom
Conversation
…m, extractor, email_intake Wave 1 of test coverage improvements for lab-manager: - test_email_poller.py (NEW): 28 tests for IMAP polling, error handling, shutdown - test_documents_route_coverage.py: +48 tests for background tasks, CRUD, review, upload - test_litellm_client.py: +4 tests for load_litellm_config - test_pubchem.py: expanded test coverage - test_extractor_coverage.py: expanded test coverage - test_email_intake.py: expanded test coverage Unit test count: 1406 → 1444 (+38 net new) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- test_api_validation.py (NEW): 58 tests for email validation (74% → 96%) - test_more_ocr_coverage.py (NEW): 68 tests for OCR providers (59% → 100%) - test_extractor_coverage.py: +12 tests for intake/extractor (82% → 98%) - test_pubchem.py: +6 tests for pubchem service (90% → 100%) - test_litellm_client.py: +18 tests for litellm client (68% → 100%) - test_email_poller.py: +31 tests for email poller (78% → 99%) - test_email_intake.py: +9 tests for email intake (90% → 100%) - test_documents_route_coverage.py: clean 56 tests (removed isolation-broken classes) Unit test count: 1406 → 1626 (+220 net new) All 1626 pass, 0 failures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The locked_until field from SQLite may be offset-naive, causing TypeError when compared with datetime.now(timezone.utc). Add tz normalization. Also add access_expires_at check during login. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PATCH could set status to approved/rejected/deleted, bypassing the review workflow. Now raises 422 for review statuses and deleted. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Route handlers should use flush() to let the session middleware handle commits. Direct commit() can cause issues with nested sessions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- receive_items: use SELECT FOR UPDATE to prevent double-receive race - transfer: reject disposed/depleted/deleted/expired items - Fix status error message formatting Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
29a4556 to
8f0fb9d
Compare
77d2bf7 to
10f3118
Compare
| staff_role_level = 4 | ||
| staff_active = False | ||
| staff_locked_until = None | ||
| staff_access_expires_at = None |
| get_settings.cache_clear() | ||
| from lab_manager.api.app import create_app | ||
|
|
||
| app = create_app() |
Member
Author
|
Closing: cascading test file conflicts make rebase impractical. Will re-apply the fix as a clean PR from main. |
1 task
robotlearning123
added a commit
that referenced
this pull request
Mar 29, 2026
## Summary
- Remove redundant `os.environ.get("EMAIL_IMAP_PASSWORD")` in
`_connect_imap`
- The function already receives password as a parameter; the env re-read
was shadowing it
Replaces #378
## Test plan
- [x] `tests/test_imap_fix.py` verifies password parameter is used (not
env)
Co-authored-by: Cong <72737794+robolearning123@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
_connect_imap(config, password)immediately overwrote thepasswordparameter withos.environ.get("EMAIL_IMAP_PASSWORD", ""), making the function signature misleading and the parameter useless.Root Cause
Copy-paste from
_get_imap_password()— the env re-read was left in when refactoring to accept password as a parameter.Fix
Removed the redundant
password = os.environ.get(...)line. The function now correctly uses the password passed by the caller.Test
2 tests: verifies parameter is used (not env var), and empty string passthrough.
🤖 Found and fixed by bug-hunter autonomous loop.