Skip to content

Fix bug related to loading and merging atmos configurations files#1175

Merged
osterman merged 3 commits intomainfrom
fix-load_multiple_config
Mar 29, 2025
Merged

Fix bug related to loading and merging atmos configurations files#1175
osterman merged 3 commits intomainfrom
fix-load_multiple_config

Conversation

@haitham911
Copy link
Collaborator

@haitham911 haitham911 commented Mar 28, 2025

What

  • Fixed an issue where multiple configuration files were not loading correctly.
  • Now, all configuration files from each specified path are loaded and merged into the Atmos config.

Why

  • Previously, when loading files from multiple paths, only the first file found was loaded, ignoring the rest. This update ensures all configurations are properly merged.

references

Summary by CodeRabbit

  • Refactor
    • Enhanced the configuration loading mechanism to improve error handling and ensure accurate processing of YAML configuration files.
  • Tests
    • Added new tests for configuration merging, including scenarios for missing configuration files and merging multiple configuration files.

@haitham911 haitham911 requested a review from a team as a code owner March 28, 2025 23:49
@haitham911 haitham911 added the bug 🐛 An issue with the system label Mar 28, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 28, 2025

📝 Walkthrough

Walkthrough

The mergeConfig function now creates a temporary Viper instance to load configurations independently. The temporary instance is set up with the same configuration path and name as the original, with an explicit configuration type of "yaml". This instance reads the configuration file, and if successful, its file path is used to update the original Viper instance. Error handling remains in place, ensuring that any issues during file reading or merging are immediately returned.

Changes

File(s) Change Summary
pkg/.../load.go Updated mergeConfig: now creates a temporary Viper instance, explicitly sets the configuration type to "yaml", reads config, and then updates the original instance with the correct file path.
pkg/.../config_test.go Added tests for mergeConfig: TestMergeConfig_ConfigFileNotFound checks error handling for missing config files; TestMergeConfig_MultipleConfigFilesMerge verifies merging of multiple config files.

Suggested labels

patch, minor

Suggested reviewers

  • aknysh
  • osterman
  • johncblandii

Possibly related PRs

  • get atmos config and vendor from .yaml or .yml #736: The changes in the main PR, specifically the modifications to the mergeConfig function for handling configuration loading, are related to the changes in the retrieved PR, which also involves configuration file handling, particularly in how the existence of configuration files is checked and processed. Both PRs focus on improving the robustness of configuration management.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 728ae92 and 3d7312a.

📒 Files selected for processing (1)
  • pkg/config/config_test.go (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: codecov/patch
  • GitHub Check: Acceptance Tests (macos-latest, macos)
  • GitHub Check: Acceptance Tests (windows-latest, windows)
  • GitHub Check: Summary
🔇 Additional comments (3)
pkg/config/config_test.go (3)

243-251: Good test coverage for config file not found scenario.

Nice work on adding this test case to verify proper error handling. This ensures the system correctly fails when configuration files are missing, which is important for debugging user issues.


253-281: Strong implementation of multiple config merge test.

This test effectively validates the core functionality being fixed in this PR. It confirms that:

  1. Config values are loaded from the first file
  2. Values from the second file override when present
  3. Values unique to the first file are preserved
  4. The config file path is correctly updated

The test structure is clear and provides good coverage of the merging logic.


9-9: Appropriate import addition.

Adding the Viper import is necessary for the new tests.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or @auto-summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @auto-title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
pkg/config/load.go (1)

203-212: Isolating config loading in a temporary Viper improves reliability.
This approach helps ensure the main instance is unaffected by any failed read. If future requirements expand to support other file types, consider dynamically detecting file formats rather than hardcoding "yaml".

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 723a0c3 and 728ae92.

📒 Files selected for processing (1)
  • pkg/config/load.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: [mock-windows] tests/fixtures/scenarios/complete
  • GitHub Check: [mock-windows] examples/demo-vendoring
  • GitHub Check: [localstack] demo-localstack
  • GitHub Check: Acceptance Tests (macos-latest, macos)
  • GitHub Check: Acceptance Tests (windows-latest, windows)
  • GitHub Check: Acceptance Tests (ubuntu-latest, linux)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary
🔇 Additional comments (2)
pkg/config/load.go (2)

214-214: Assigning the config file to the main Viper instance is clear and consistent.
This ensures subsequent merges target the correct path.


219-219: Reading the configuration file content here is sensible.
It cleanly feeds into the YAML preprocessing logic.

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 28, 2025
@codecov
Copy link

codecov bot commented Mar 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 28.29%. Comparing base (723a0c3) to head (3d7312a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1175      +/-   ##
==========================================
+ Coverage   28.25%   28.29%   +0.03%     
==========================================
  Files         182      182              
  Lines       21274    21284      +10     
==========================================
+ Hits         6012     6022      +10     
  Misses      14312    14312              
  Partials      950      950              
Flag Coverage Δ
unittests 28.29% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@haitham911 haitham911 requested a review from osterman March 29, 2025 00:07
@osterman osterman added the patch A minor, backward compatible change label Mar 29, 2025
@osterman osterman removed the bug 🐛 An issue with the system label Mar 29, 2025
@osterman osterman changed the title fix bug load atmos configurations files Fix bug relaree to loading and merging atmos configurations files Mar 29, 2025
@osterman osterman changed the title Fix bug relaree to loading and merging atmos configurations files Fix bug related to loading and merging atmos configurations files Mar 29, 2025
@osterman osterman merged commit 448bab5 into main Mar 29, 2025
62 checks passed
@osterman osterman deleted the fix-load_multiple_config branch March 29, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants