fix: add refresh-interval validation#678
Conversation
Signed-off-by: Aditya Chopra <adityachopra2912@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #678 +/- ##
=========================================
- Coverage 10.99% 7.17% -3.82%
=========================================
Files 173 260 +87
Lines 8671 12850 +4179
=========================================
- Hits 953 922 -31
- Misses 7612 11820 +4208
- Partials 106 108 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
CC: @bupd @qcserestipy
So even though we are successfully catching the error, the CLI doesnt show it, which I think isnt ideal. What do you think? |
|
There are 2 options in my opinion to fix this :
fmt.Fprintf(os.Stderr, "Error: invalid refresh interval: %v\n", err)
os.Exit(1)during the CLI input validation, we will have to make this change in all the CLI commands. I looked online for what is better approach, and although they say that the first option make the CLI slighly slow(because this happens at init), I would recommend that only, because I dont think it is that significant, and it is cleaner implementation. |
|
Great investigation! that's an important UX issue - the error gets swallowed because the logger isn't configured yet. I think Option 2 is the better approach for a few reasons:
For the implementation, using
One small suggestion: You could wrap this in a helper function to keep it DRY across commands: func validateRefreshInterval(interval time.Duration) {
if interval <= 0 {
fmt.Fprintf(os.Stderr, "Error: invalid refresh interval: %v\n", interval)
os.Exit(1)
}
}Then just call |
|
Why not keep it simple? And return an error? |
sounds cool and maintainable to me |
|
I'd also suggest @NucleoFusion's point. We can simply return an error and make it a |
|
Yeah that sounds good. Will do that. |
Signed-off-by: Aditya Chopra <adityachopra2912@gmail.com>
|
@adityachopra29 that is a seperate PR. Already being worked upon (if not, feel free to have a look) |
|
Oh okay..... |
qcserestipy
left a comment
There was a problem hiding this comment.
Thank you for fixing this bug! LGTM

Summary of Changes
refresh-interval>= a threshold ( 500ms )