Skip to content

fix: only error if config is directly provided#52

Merged
dacbd merged 2 commits intomainfrom
dacbd/config-warning
Feb 14, 2026
Merged

fix: only error if config is directly provided#52
dacbd merged 2 commits intomainfrom
dacbd/config-warning

Conversation

@dacbd
Copy link
Collaborator

@dacbd dacbd commented Feb 14, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved configuration file error handling: the app now logs a warning and continues when no config file is provided, instead of exiting. Supplying an explicit config file still yields a fatal error on read failures.
    • Reduces unexpected termination for users running without a config file, improving startup resilience.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 14, 2026

📝 Walkthrough

Walkthrough

Modified config initialization error handling in one file: added a configProvided flag and changed ReadInConfig failure handling to exit only when a config file was explicitly supplied; otherwise a warning is logged and execution continues.

Changes

Cohort / File(s) Summary
Config Error Handling
cmd/ctrlc/ctrlc.go
Added configProvided flag; viper.ReadInConfig errors now cause exit only when cfgFile != ""; when no config path is provided the error is logged as a warning and the process continues.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I sniffed the config, hopped to see,
A little flag said "was this given to me?"
If yes, I stop on error with care,
If not, I warn and nibble on air —
Forward we go, with a twitch and a flair. 🥕

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: conditional error handling based on whether a config file was explicitly provided.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dacbd/config-warning

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 1

🤖 Fix all issues with AI agents
In `@cmd/ctrlc/ctrlc.go`:
- Around line 48-51: The code currently only sets configProvided = true when the
flag-backed variable cfgFile is non-empty, so the environment variable bound via
viper.BindEnv("config", ...) never causes the file to be treated as provided;
either explicitly read viper.GetString("config") into cfgFile (or set
configProvided) before the cfgFile check or remove the misleading
viper.BindEnv("config", ...) if env-based config file paths are not supported;
update the logic around cfgFile, configProvided, and the viper.SetConfigFile
call (functions/variables: cfgFile, configProvided, viper.BindEnv("config",
...), viper.SetConfigFile) so an env-provided path behaves the same as --config
or the env binding is removed.

@dacbd dacbd merged commit b8498d7 into main Feb 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant