<#9386 fix: support both .yaml and .yml extensions...
# meltano-repo-activity
g
#9386 fix: support both .yaml and .yml extensions for logging config files Pull request opened by mahangu I thought I'd try another
good first issue
but I'm not at all familiar with the codebase yet so I'm sure I'll need some feedback and direction here. Thank you for taking a look! 🙏🏾 ## Summary Adds fallback support for logging configuration files to work with both
.yaml
and
.yml
extensions. When Meltano cannot find the specified logging config file, it now tries the alternate extension automatically. Closes #7013 ## Changes • Modified
setup_logging()
in
src/meltano/core/logging/utils.py
to add bidirectional fallback logic • Added fallback message logging to inform users when alternate filename is used • Updated documentation to mention support for both extensions • Added comprehensive test coverage for both fallback scenarios ## Implementation Details • Uses
pathlib.Path
for robust file extension handling • Only attempts fallback for YAML files (`.yaml`/`.yml` extensions) • Logs fallback usage after logging system is configured • Maintains backward compatibility (default remains
logging.yaml
) ## Test Plan ### Automated Tests • Added
test_setup_logging_yml_extension_fallback()
covering both fallback directions • All existing tests pass with no regressions ### Manual Testing Test with modified Meltano: # Install modified version cd /path/to/meltano python3 -m venv test_env && source test_env/bin/activate pip install -e . && meltano init test_fallback && cd test_fallback # Create logging.yaml with custom format cat > logging.yaml << 'EOF' version: 1 formatters: custom: format: 'YAML: %(levelname)s - %(message)s' handlers: console: class: logging.StreamHandler formatter: custom root: level: INFO handlers: [console] EOF # Test .yml → .yaml fallback (specify .yml but only .yaml exists) MELTANO_CLI_LOG_CONFIG=logging.yml meltano --log-level=info config Expected output:
Copy code
YAML: INFO - {'event': 'Using logging config from logging.yaml (fallback from logging.yml)', 'level': 'info', 'timestamp': '2025-07-17T02:52:40.089712Z'}
Usage: meltano config [OPTIONS] PLUGIN_NAME COMMAND [ARGS]...
...
Test .yaml → .yml fallback: # Rename file to test opposite direction mv logging.yaml logging.yml # Test fallback from .yaml to .yml (specify .yaml but only .yml exists) MELTANO_CLI_LOG_CONFIG=logging.yaml meltano --log-level=info config Expected output:
Copy code
YAML: INFO - {'event': 'Using logging config from logging.yml (fallback from logging.yaml)', 'level': 'info', 'timestamp': '2025-07-17T02:52:00.316004Z'}
Usage: meltano config [OPTIONS] PLUGIN_NAME COMMAND [ARGS]...
...
Key observations: • ✅ Fallback message appears showing exact source and target files • ✅ Custom format
YAML: INFO -
is used (proving config loaded successfully) • ✅ Both directions work:
.yml
↔️
.yaml
Verify fix necessity with fresh installation: # Test with unmodified Meltano python -m venv fresh_env && source fresh_env/bin/activate pip install meltano && meltano init test_fresh && cd test_fresh # Create only logging.yml (with custom format) cat > logging.yml << 'EOF' version: 1 formatters: custom: format: 'FRESH: %(levelname)s - %(message)s' handlers: console: class: logging.StreamHandler formatter: custom root: level: INFO handlers: [console] EOF # Try to use .yaml (should fail silently in unmodified version) MELTANO_CLI_LOG_CONFIG=logging.yaml meltano --help # Expected: Standard format (no "FRESH:" prefix), confirming fallback doesn't exist This enables users to use either
.yaml
or
.yml
extensions interchangeably for their logging configuration files. ## Summary by Sourcery Add bidirectional extension fallback for logging configuration files so that specifying either .yaml or .yml will automatically load the alternate if the specified file is not found. New Features: • Add automatic fallback between .yaml and .yml extensions when loading logging configuration files Enhancements: • Log an informational message when a fallback configuration file is used Documentation: • Update documentation to mention support for both .yaml and .yml extensions in logging config Tests: • Add tests covering both .yaml→.yml and .yml→.yaml fallback scenarios in setup_logging meltano/meltano