Commit Graph

630 Commits

Author SHA1 Message Date
copilot-swe-agent[bot] 195c3c3446 fix(tasks): dispatch per-user notifications on document processed/failed events
The per-user notification functions (notify_user_document_processed /
notify_user_document_failed) were defined but never called from the
document processing pipeline.

- Call notify_user_document_processed in finalize_document_storage
  when owner_id is available (creates in-app + email/webhook notifications)
- Add _dispatch_user_failure_notification helper to celery_app.py that
  extracts file_id from failed task args and dispatches
  notify_user_document_failed for document pipeline tasks
- Add comprehensive tests for both success and failure notification paths

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 16:10:01 +00:00
Christian Krakau-Louis ebbbd3d62e Merge pull request #731 from christianlouis/copilot/fix-mobile-app-login
fix: resolve CI failures from stale request mocks, Annotated+Depends pattern, and CodeQL sensitive data logging
2026-03-16 15:29:15 +01:00
copilot-swe-agent[bot] 0444b14d87 fix(test): update url_upload test mocks from requests to httpx
The tests were patching `app.api.url_upload.requests.get` but the module
uses `httpx.AsyncClient`. Updated 4 tests across 2 files to use the
correct `httpx.AsyncClient.stream` mock pattern with `AsyncMock`,
matching the existing working tests in test_url_upload.py.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 13:03:18 +00:00
Christian Krakau-Louis c81914f78d Merge pull request #729 from christianlouis/copilot/add-default-language-version-support
feat(translation): automatic document translation to configurable default language
2026-03-16 13:55:25 +01:00
copilot-swe-agent[bot] 075a505085 feat(profile): expose default_document_language in profile API and UI
- Add default_document_language to ProfileResponse and ProfileUpdateRequest
- Handle validation in PATCH /api/profile endpoint
- Add dropdown in profile.html template with Alpine.js binding
- Add translation keys for profile UI labels
- Add comprehensive tests for profile default language feature

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 12:13:54 +00:00
copilot-swe-agent[bot] 8cc817930d Merge remote-tracking branch 'origin/main' into copilot/fix-mobile-app-login 2026-03-16 11:58:14 +00:00
copilot-swe-agent[bot] 9d6bfde288 feat(tasks): extract and map embedded PDF metadata in upload_to_email
Implement extraction of embedded PDF metadata using pypdf, mapping
/Title, /Author, /Subject, /Keywords to filename, absender,
document_type, and tags respectively. JSON metadata takes precedence;
PDF metadata fills missing fields only.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 11:27:34 +00:00
copilot-swe-agent[bot] 9a256741d5 fix(auth): address review comments - improve debug logging, use SimpleNamespace, fix session cleanup
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 11:26:52 +00:00
copilot-swe-agent[bot] 15a9ed9435 fix(auth): resolve Bearer token in get_current_owner_id for mobile API auth
get_current_owner_id() only checked the session for authenticated users.
When the mobile app sends Authorization: Bearer <token>, there is no
session cookie, so the Depends(_get_owner_id) dependency raised HTTP 401
before the @require_login wrapper could resolve the Bearer token.

The function now checks three sources in order:
1. Session user dict (existing behavior)
2. request.state.api_token_user (cached by require_login or prior call)
3. Direct Bearer token resolution via _resolve_bearer_user (new)

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 11:25:02 +00:00
Christian Krakau-Louis 3447a408db Merge pull request #714 from christianlouis/perf/async-onedrive-token-refresh-7215258063318287629
 Async OneDrive token validation using httpx
2026-03-16 12:15:39 +01:00
Christian Krakau-Louis b8a1ac52b3 Merge branch 'main' into perf/async-url-upload-7099409897484162483 2026-03-16 12:12:21 +01:00
Christian Krakau-Louis cb1e81355d Merge pull request #726 from christianlouis/add-tests-saved-searches-4325714364005279059
🧪 Add tests for saved searches API
2026-03-16 12:08:31 +01:00
copilot-swe-agent[bot] c7ff177e17 fix: resolve test failures and mypy errors on main
- Fix Dropbox tests: patch httpx.AsyncClient instead of non-existent requests.post
- Add SETTING_METADATA entries for 6 logging settings (log_level, log_format, log_syslog_*)
- Add types-aiofiles to dev dependencies to fix mypy import-untyped error

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 10:32:20 +00:00
github-actions[bot] 46c4031276 style: apply ruff auto-fix
- Auto-formatted code with ruff format
- Applied ruff linting fixes with --fix

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-03-16 10:23:16 +00:00
google-labs-jules[bot] 7798ac3b57 🧪 Add tests for saved searches API endpoints
Added a new test file `tests/test_api_saved_searches.py` containing a comprehensive test suite for the CRUD operations provided in `app/api/saved_searches.py`. The suite validates happy paths, error conditions (like missing filters, name limits, duplicates), and user isolation using an in-memory SQLite database.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 10:22:18 +00:00
Christian Krakau-Louis 740d18555b Merge pull request #707 from christianlouis/copilot/fix-debug-logging-issue
feat: fix DEBUG logging and add LOG_LEVEL/LOG_FORMAT/LOG_SYSLOG for standard log management
2026-03-16 11:00:41 +01:00
Christian Krakau-Louis e679b71356 Merge pull request #697 from christianlouis/test-api-tokens-hash-token-18108337743020909528
🧪 Add unit test for hash_token function
2026-03-16 10:58:44 +01:00
Christian Krakau-Louis bcd49aa793 Merge pull request #695 from christianlouis/fix/rename-save-dropbox-settings-9203732237520055590
🧹 [code health improvement] Rename save_dropbox_settings to save_google_drive_settings
2026-03-16 10:58:07 +01:00
Christian Krakau-Louis 1c8cebb718 Merge pull request #694 from christianlouis/add-test-delete-saved-search-error-10537352409448038219
🧪 add error test for deleting saved search
2026-03-16 10:57:24 +01:00
Christian Krakau-Louis 3be78708cd Merge pull request #716 from christianlouis/code-health/simplify-save-onedrive-settings-12338634662690804221
🧹 [Code Health] Simplify save_onedrive_settings logic and extract env_utils
2026-03-16 10:56:25 +01:00
Christian Krakau-Louis 992adad978 Merge pull request #718 from christianlouis/perf-upload-15584535240168516797
 Optimize file upload endpoint to use asynchronous aiofiles
2026-03-16 10:55:57 +01:00
google-labs-jules[bot] 827979598e perf(onedrive): use async httpx for token refresh
Replaces the synchronous `requests.post` and `requests.get` calls in
`app/api/onedrive.py:test_onedrive_token` with an asynchronous
`httpx.AsyncClient` implementation. This unblocks the FastAPI event loop
when this endpoint is hit.

Fixed unused requests import in `app/api/onedrive.py` and sorted imports in the testing files updated previously to adhere to the repository formatting (`ruff check --fix`). Tests in `test_api_onedrive_extended.py` were also migrated to use AsyncMock properly.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 09:53:14 +00:00
Christian Krakau-Louis b9b8796153 Merge pull request #699 from christianlouis/improve-generate-api-token-coverage-1443605259252817388
🧪 Add unit tests for `generate_api_token`
2026-03-16 10:53:06 +01:00
Christian Krakau-Louis b3d1824d66 Merge pull request #700 from christianlouis/extract-pdf-metadata-upload-to-email-12238364102013658937
Extract embedded PDF metadata using pypdf
2026-03-16 10:52:51 +01:00
Christian Krakau-Louis e29e222833 Merge pull request #704 from christianlouis/test-settings-sync-error-handling-9908300433097254406
🧪 Add tests for notify_settings_updated error handling
2026-03-16 10:52:15 +01:00
Christian Krakau-Louis 0d606d480f Merge pull request #706 from christianlouis/test-saved-searches-update-3763426346293976504
🧪 Add error tests for updating saved searches
2026-03-16 10:51:37 +01:00
Christian Krakau-Louis a9af06ed17 Merge pull request #708 from christianlouis/test-create-saved-search-errors-7017236575137054898
🧪 Add missing error tests for create_saved_search
2026-03-16 10:51:18 +01:00
copilot-swe-agent[bot] 6da1e6fd81 feat(config): add JSON structured logging and syslog forwarding for application logs
- Add LOG_FORMAT setting (text/json) for structured JSON log output
- Add LOG_SYSLOG_* settings for direct syslog forwarding of app logs
- JSON format compatible with Grafana Loki, Splunk, ELK, Datadog
- Syslog forwarding uses Python's SysLogHandler (UDP/TCP)
- Update .env.demo and ConfigurationGuide.md with all new settings
- Add tests for JSON formatter and syslog config fields

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 09:51:16 +00:00
Christian Krakau-Louis 50846360b3 Merge pull request #712 from christianlouis/test-settings-sync-coverage-16903900720046903542
🧪 [testing improvement] add missing error logging tests for notify_settings_updated
2026-03-16 10:50:40 +01:00
Christian Krakau-Louis 13a156f4e3 Merge pull request #709 from christianlouis/test-settings-sync-5418518550614493591
🧪 Add tests for settings_sync utility
2026-03-16 10:50:02 +01:00
Christian Krakau-Louis c00a35bbac Merge pull request #711 from christianlouis/performance-optimize-dropbox-token-2748375428782384195
 Optimize Dropbox token check by using async httpx
2026-03-16 10:49:34 +01:00
Christian Krakau-Louis 635966b099 Merge pull request #715 from christianlouis/test-api-tokens-coverage-14568212820727238898
🧪 Add tests for api_tokens edge cases
2026-03-16 10:49:04 +01:00
google-labs-jules[bot] 21f9998706 Fix tests affected by os.path mock updates in onedrive coverage
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 09:48:38 +00:00
Christian Krakau-Louis 3088459c70 Merge pull request #713 from christianlouis/perf/fix-notifications-api-n-plus-1-17980566457111073264
 Fix N+1 Query in Notification Preferences Update
2026-03-16 10:46:12 +01:00
google-labs-jules[bot] 320a2acedd perf: optimize url upload with async i/o
Replaced synchronous `requests.get` and `open().write` in the `process_url` endpoint with `httpx.AsyncClient` and `aiofiles.open`. This prevents the FastAPI event loop from blocking during large file downloads.

Updated test suite in `tests/test_url_upload.py` to use `AsyncMock` to mock `httpx.AsyncClient.stream` contexts and async generators properly, covering all original conditions and HTTP error handling paths.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 09:41:17 +00:00
google-labs-jules[bot] d58c43c7b5 🧪 Fix test_api_tokens syntax to avoid CI failures in older Python versions
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 09:39:41 +00:00
github-actions[bot] 6f5f4d9d49 style: apply ruff auto-fix
- Auto-formatted code with ruff format
- Applied ruff linting fixes with --fix

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-03-16 09:36:54 +00:00
google-labs-jules[bot] 9a85615811 🧪 Add tests for settings_sync.py register_settings_reload_signal
This commit improves test coverage for the `register_settings_reload_signal` function in `app/utils/settings_sync.py`.

🎯 **What:** The testing gap addressed was that the `_reload_if_stale` inner Celery `task_prerun` signal handler was entirely untested, specifically around exception handling (e.g. Redis timeouts or OCR manager errors) and the code branch where Redis returns no version key.

📊 **Coverage:** The following scenarios are now tested:
- Redis returning `None` for the version.
- Redis throwing an exception (handled gracefully).
- `ensure_ocr_languages_async` throwing an exception (caught and logged without failing the task).

 **Result:** Test coverage for `register_settings_reload_signal` is now 100%. Total coverage for `app/utils/settings_sync.py` has been substantially improved.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 09:36:33 +00:00
google-labs-jules[bot] b290cffb98 Performance Optimization: Replace synchronous file upload read with async aiofiles
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 09:36:33 +00:00
copilot-swe-agent[bot] 18c49c6b2d feat(config): add LOG_LEVEL setting and configure root logging at startup
- Add `log_level` setting to config.py (default: INFO, env: LOG_LEVEL)
- Configure Python root logger in main.py with standard precedence:
  LOG_LEVEL explicit > DEBUG=true implies DEBUG > default INFO
- Add timestamp to log format for production readability
- Suppress noisy third-party loggers at DEBUG level
- Add comprehensive debug logging to all auth functions
- Add LOG_LEVEL/DEBUG to .env.demo and ConfigurationGuide.md
- Add tests for logging config and auth debug output

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 09:33:50 +00:00
github-actions[bot] ac35c5e6fa style: apply ruff auto-fix
- Auto-formatted code with ruff format
- Applied ruff linting fixes with --fix

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-03-16 09:28:26 +00:00
google-labs-jules[bot] 94dc6f967d Fix ruff lint error in tests/test_api_dropbox.py
Removed unused `import requests` from `tests/test_api_dropbox.py`.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 09:28:08 +00:00
github-actions[bot] 0425d46c44 style: apply ruff auto-fix
- Auto-formatted code with ruff format
- Applied ruff linting fixes with --fix

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-03-16 09:26:26 +00:00
google-labs-jules[bot] f24c39a027 🧪 Add tests for api_tokens edge cases to improve coverage
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 09:26:04 +00:00
github-actions[bot] ca2d023d81 style: apply ruff auto-fix
- Auto-formatted code with ruff format
- Applied ruff linting fixes with --fix

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-03-16 09:25:47 +00:00
google-labs-jules[bot] 7242f3c168 perf(onedrive): use async httpx for token refresh
Replaces the synchronous `requests.post` and `requests.get` calls in
`app/api/onedrive.py:test_onedrive_token` with an asynchronous
`httpx.AsyncClient` implementation. This unblocks the FastAPI event loop
when this endpoint is hit.

Tests were updated to mock `httpx.AsyncClient` and a sync wrapper using `asyncio.run` was added to integration tests to maintain test coverage without massive test refactoring.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 09:24:58 +00:00
github-actions[bot] 8bb6457c65 style: apply ruff auto-fix
- Auto-formatted code with ruff format
- Applied ruff linting fixes with --fix

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-03-16 09:23:40 +00:00
github-actions[bot] c1657a01a7 style: apply ruff auto-fix
- Auto-formatted code with ruff format
- Applied ruff linting fixes with --fix

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-03-16 09:23:07 +00:00
google-labs-jules[bot] dab881b9b6 Fix ruff linting errors in test_settings_sync.py
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 09:22:46 +00:00
github-actions[bot] 705c801158 style: apply ruff auto-fix
- Auto-formatted code with ruff format
- Applied ruff linting fixes with --fix

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-03-16 09:22:19 +00:00