Skip to content

BitwardenAPIClient fails with real bitwarden server #40

@uedvt359

Description

@uedvt359

I'm trying to use your nice library to migrate some data from a self-hosted Bitwarden to a self-hosted Vaultwarden.

Hence, I am opening a connection to both softwares. There seems to be an incompatibility with the original Bitwarden software:

bitwarden_client = BitwardenAPIClient(
    url="https://bitwarden.example.org",
    email="[email protected]",
    password="...",
    client_id="...",
    client_secret="...",
    device_id="..."
)
vaultwarden_client = BitwardenAPIClient(
    url="https://vaultwarden.example.org",
    email="[email protected]",
    password="...",
    client_id="...",
    client_secret="...",
    device_id="..."
)

vw_data = vaultwarden_client.sync() # works
print(vw_org.collections()) # works

bw_data = bitwarden_client.sync() # fails
print(bw_org.collections()) # fails

It seems, Bitwarden returns less data than Vaultwarden. In both cases (.sync() and .collections()), this exception is generated:

Traceback (most recent call last):
  File "myscript.py", line 58, in <module>
    print(bitwarden_client.sync())
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/vaultwarden/clients/bitwarden.py", line 138, in sync
    self._sync = SyncData.model_validate_json(resp.text)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pydantic/main.py", line 766, in model_validate_json
    return cls.__pydantic_validator__.validate_json(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 2 validation errors for SyncData
profile.name
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
profile._status
  Field required [type=missing, input_value={'id': 'aaaaaaaa-bbbb-ccc...[], 'object': 'profile'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/missing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions