<#9400 feat(core): Add log file support for uv ven...
# meltano-repo-activity
g
#9400 feat(core): Add log file support for uv venv backend installation errors Pull request opened by mahangu ## Summary This PR implements log file creation and user notification for the
uv
venv backend when plugin installation fails, bringing it to parity with the existing
pip
backend behavior. This change improves the developer experience by providing the same helpful debugging information for both venv backends, making it easier to troubleshoot plugin installation issues. ## Background Previously, when plugin installation failed using the
uv
venv backend, users received only a generic error message without being pointed to a log file for debugging. The
pip
backend already provided this functionality by using pip's
--log
flag and informing users of the log file location. Since
uv
doesn't currently support a
--log
CLI option (tracked in astral-sh/uv#9850), this PR implements a workaround by manually creating detailed log files when installation errors occur. ## Changes ### Core Implementation (
src/meltano/core/venv_service.py
) 1. Enhanced
UvVenvService.handle_installation_error()
to create log files and inform users: • Creates log directory if it doesn't exist • Writes detailed error information to the same log path as pip backend • Informs users about the log file location via
logger.info()
2. Added
UvVenvService._write_error_log()
helper method
for clean separation of concerns: • Captures timestamp of failure • Records the exact command that failed • Includes full error output from uv • Uses structured, readable format ### Test Coverage (
tests/meltano/core/test_venv_service.py
) 1. Enhanced existing test to verify log file creation and content 2. Added new test for graceful handling of log write failures ## User Experience ### Before
Copy code
ERROR: Failed to install plugin 'tap-csv'.
### After
Copy code
ERROR: Failed to install plugin 'tap-csv'.
INFO: Logged uv pip install output to /path/to/project/.meltano/logs/pip/extractors/tap-csv/pip.log
### Log File Content Example
Copy code
--- Installation attempt failed at 2025-01-21T15:30:45.123456 ---
Command: uv pip install --python=/path/to/venv/bin/python
Error output:
ERROR: Could not find a version that satisfies the requirement invalid-package
--- End of error log ---
## Implementation Details • Consistent with pip backend: Uses identical log file paths and user messaging • Robust error handling: Gracefully handles log write failures with debug logging ## Manual Testing To test this feature: 1. Setup dev environment: uv pip install -e . uv run meltano init test-project && cd test-project echo "venv_backend: uv" >> meltano.yml 2. Trigger installation failure: uv run meltano add extractor tap-csv # Edit meltano.yml: change pip_url to "nonexistent-package==99.99.99" uv run meltano install extractor tap-csv 3. Verify log file creation: • Look for info message pointing to log file path
2025-07-22T025640.746882Z [info ] Logged uv pip install output to /Users/mahangu/code/meltano3/worktrees/9016/test-uv-demo/demo-project/.meltano/logs/pip/extractors/tap-csv/pip.log
• Examine log file for timestamp, command, and error details
cat /Users/mahangu/code/meltano3/worktrees/9016/test-uv-demo/demo-project/.meltano/logs/pip/extract
ors/tap-csv/pip.log
--- Installation attempt failed at 2025-07-22T025640.746705+00:00 ---
Command: /Users/mahangu/code/meltano3/worktrees/9016/.venv/bin/uv pip install --python=/Users/mahangu/code/meltano3/worktrees/9016/test-uv-demo/demo-project/.meltano/extractors/tap-csv/venv/bin/python
Error output:
Using Python 3.12.9 environment at: .meltano/extractors/tap-csv/venv
Updating https://github.com/MeltanoLabs/tap-csv.gitz (HEAD)
error: Git operation failed
Caused by: failed to clone into: /Users/mahangu/.cache/uv/git-v0/db/5e90adcedfb4e007
Caused by: process didn't exit successfully:
/usr/bin/git fetch --force --update-head-ok 'https://github.com/MeltanoLabs/tap-csv.gitz' '+HEAD:refs/remotes/origin/HEAD'
(exit status: 128)
--- stderr
fatal: could not read Username for 'https://github.com': terminal prompts disabled
--- End of error log ---
--- Closes #9016 ## Summary by Sourcery Enable detailed logging and user notification for installation failures in the uv venv backend, aligning its behavior with the pip backend. New Features: • Log installation errors to a timestamped log file and inform users of its location for the uv venv backend Enhancements: • Add _write_error_log helper to capture timestamp, failed command, and stderr output • Handle log writing failures gracefully to prevent cascading errors Tests: • Add tests for log file creation on installation error and graceful handling of log write failures meltano/meltano