Improve secure key env var match default case#20097
Conversation
|
|
New Issues (23)Checkmarx found the following issues in this Pull Request
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #20097 +/- ##
==========================================
+ Coverage 46.67% 46.82% +0.14%
==========================================
Files 3880 3882 +2
Lines 116114 116386 +272
Branches 17671 17738 +67
==========================================
+ Hits 54200 54498 +298
+ Misses 59447 59409 -38
- Partials 2467 2479 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| Err(error) => { | ||
| info!( | ||
| "{} is not a valid secure key container backend, using automatic selection", | ||
| env_var.unwrap_or_default() | ||
| %error, | ||
| env_var = ENV_VAR_SECURE_KEY_CONTAINER_BACKEND, | ||
| "failed to read environment variable, using automatic selection" | ||
| ); |
There was a problem hiding this comment.
💭 The hot path here is users not setting SECURE_KEY_CONTAINER_BACKEND and us using automatic selection.
I would suggest matching on std::env::VarError::NotPresent and just having a debug! or no log for that. Then having the other error options being what you have here.
Feels like unhelpful noise to have something like:
INFO error=environment variable not found env_var=SECURE_KEY_CONTAINER_BACKEND failed to read environment variable, using automatic selection







🎟️ Tracking
📔 Objective
Improves the logging of the default case for the secure key env var check.
I noticed this while observing tracing output from ssh agent. It reads:
, notably, the default match case is currently doing two things that could be improved: if the env var is not set, the log statement doesn't reflect that because it's an empty string. It doesn't delineate between the Ok(string) case and the Err case. Even though both result in a None return, it's more clear to read the logs what is going on.
Sine the existing code had
infofor both cases, I'm assuming the env var is not required/expected (hence using info for the Err case, instead of something like error or warn).