New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SM-1147] Switch to try_init with pyo3_log #676
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #676 +/- ##
==========================================
- Coverage 60.61% 60.59% -0.02%
==========================================
Files 170 170
Lines 10387 10390 +3
==========================================
Hits 6296 6296
- Misses 4091 4094 +3 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, we're already doing the same thing for the c and napi bindings, seems like we forgot this one.
sdk/crates/bitwarden-c/src/c.rs
Line 27 in 67e743f
let _ = env_logger::try_init(); |
sdk/crates/bitwarden-napi/src/client.rs
Lines 34 to 36 in 67e743f
let _ = env_logger::Builder::from_default_env() | |
.filter_level(convert_level(log_level.unwrap_or(LogLevel::Info))) | |
.try_init(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
4c5b926
Added a comment and |
I'm sorry for the dumb question, but how to implement this fix on my side? I'm using Bitwarden Secrets with the ansible lookup plugin. I did |
@mittkkoo, I'm facing the same issue as you with the Ansible integration. If you followed the directions for setup in the Bitwarden Documentation, I believe it doesn't use the I think we must wait until a new version of |
Type of change
Objective
When running the
ansible-playbook
command, we needed to export the following variable:export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
. This suppresses fork safety warnings on Mac OS. With this set, you can safely query for individual secrets. However, if you query for secrets within an Ansible loop or with a Jinja2 template, we receive an error that is caused by setting up a logger more than once. (This error comes from thepyo3_log
crate.)If we switch to using the
pyo3_log::try_init
function, we ignore the case where a logger is already set up if the attempt fails. This happens because thepyo3_log::init
function can panic. This also introduces panic safety.Code changes
try_init
Before you submit