Skip to content
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

Python problem when creating multiple BitwardenClients #994

Closed
1 task done
nisutec opened this issue Aug 26, 2024 · 3 comments
Closed
1 task done

Python problem when creating multiple BitwardenClients #994

nisutec opened this issue Aug 26, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@nisutec
Copy link

nisutec commented Aug 26, 2024

Steps To Reproduce

  1. Creating a Python file with the following class
from bitwarden_sdk import BitwardenClient, DeviceType, client_settings_from_dict
import os


class BitwardenController:
    def __init__(self):
        self.__client = BitwardenClient(
            client_settings_from_dict(
                {
                    "apiUrl": os.environ.get("BW_API_URL"),
                    "deviceType": DeviceType.SDK,
                    "identityUrl": os.environ.get("BW_IDENTITY_URL"),
                    "userAgent": "Python",
                }
            )
        )
        self.__organization_id = os.environ.get("BW_ORGANIZATION_ID")
        self.__client.access_token_login(os.environ.get("BW_ACCESS_TOKEN"))

    async def get_secret_by_uuid(self, secret_id: str):
        return self.__client.secrets().get(secret_id)

    async def get_secret_list(self) -> list | None:
        all_secrets = self.__client.secrets().list(self.__organization_id).to_dict()
        if not all_secrets['success']:
            return None
        return all_secrets['data']['data']
  1. Create a second Python file where you use the class twice
from bitwarden.test import BitwardenController

bw = BitwardenController()
bw2 = BitwardenController()
  1. Set the needed environment variables
  2. Run second Python file

Expected Result

It should be possible to create two instances from the BitwardenController class (BitwardenClient) without error.

Actual Result

if you create two BitwardenController classes (BitwardenClient). The BitwardenClient throws the following error and kills the process.

  File ".../bitwarden/test.py", line 7, in __init__
    self.__client = BitwardenClient(
                    ^^^^^^^^^^^^^^^^
  File ".../.venv/lib/python3.12/site-packages/bitwarden_sdk/bitwarden_client.py", line 13, in __init__
    self.inner = bitwarden_py.BitwardenClient(settings_json)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: SetLoggerError(())

Screenshots or Videos

No response

Additional Context

No response

Operating System

macOS

Operating System Version

No response

Build Version

bitwarden-sdk 0.1.0

Issue Tracking Info

  • I understand that work is tracked outside of Github. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress.
@nisutec nisutec added the bug Something isn't working label Aug 26, 2024
@bitwarden bitwarden deleted a comment Aug 26, 2024
@bitwarden bitwarden deleted a comment Aug 26, 2024
@Hinton
Copy link
Member

Hinton commented Aug 26, 2024

This was fixed in #676, and will be available in the next release.

@Hinton Hinton closed this as completed Aug 26, 2024
@betermieux
Copy link

This was fixed in #676, and will be available in the next release.

Sorry, don't want to be rude, but that PR was merged in April, do you have an ETA for release?

@Hinton
Copy link
Member

Hinton commented Sep 5, 2024

The team is working on publishing new versions of all the SDKs. I don't have a date but it should be soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants
@Hinton @betermieux @nisutec and others