bitwarden / cli

The command line vault (Windows, macOS, & Linux).
https://bitwarden.com
GNU General Public License v3.0
1.62k stars 174 forks source link

1.21.1 regressed compared to 1.19.1. `bw list items` became unreliable #490

Closed aptly-io closed 2 years ago

aptly-io commented 2 years ago

Describe the Bug

bw --raw list items sometimes returns an empty list while there are items bw --raw get item <uuid> sometimes cannot find an existing item

Steps To Reproduce

A python script to synchronise credentials between Keepass and Bitwarden has unit tests. Some unit tests started failing since using bw 1.21.1. These worked fine with 1.19.1

Expected Result

listing items or retrieving an item by its uuid should behave consistent with a new version Bitwarden client.

Actual Result

bw --raw list items sometimes returns an empty list bw --raw get item <uuid> sometimes cannot find existing item

Screenshots or Videos

There's only some logging

Environment

Additional Context

Python uses the subprocess module to talk with the Bitwarden client command line tool

Timmy-Tenders commented 2 years ago

Using bitwarden version 1.21.1 I have a similar issue when using bw list items nothing shows up. However, if using the 1.19.1 this list does return all of the items. This occures when using bw sync before and after as well.

Bw version 1.21.1 OS Linux Bash 5.1.16(1)-release

dh024 commented 2 years ago

I am experiencing the same empty list returned using BW CLI v. 1.21.1 on MacOS 10.14 (Bash shell) and the command:

bw list items

The same command works in an older version of the CLI (1.18.1) on the same machine.

aptly-io commented 2 years ago

Last weekend, I tried to replicate this issue again with some simplified code and extra logging. But I failed to replicate the issue (I had removed bitwarden/node/npm from my Macbook) with version 1.21.1 @Timmy-Tenders @dh024 could you check what versions of node and npm you have?

dh024 commented 2 years ago

You bet.

Node: v16.11.1 NPM: 8.0.0

eliykat commented 2 years ago

I can't replicate this exactly, although if I follow the upgrade path from 1.19.0 to 1.21.1 I do get a series of mac failed. errors before the command output. I'll investigate further.

In the meantime, you may be able to solve this by clearing your local CLI data (see here for a list of locations) and then logging in again. This will force a refresh of your local machine's data, which I suspect may have been upset by the upgrade process. (Note: this will require you to re-authenticate with the server.)

Please let me know if this fixes the issue.

dh024 commented 2 years ago

@eliykat Yes, this worked. Many thanks. I'll post the fix on the community forums. Cheers!

jdecaron commented 2 years ago

@eliykat why did you close this issue?

This bug is still happening on 1.21.1:

bw list items
[]

bw --version
1.21.1

This bug started to appear on 2022-02-16 (just a few days after the release of 1.21.0). This bug happens every day or sometimes every other day on my system. 1.21.1 didn't fix the issue. It's not possible to know from the "detailed" release note if you guys fixed the bug or not.

Please reopen this issue and only close this issue when you really solved it, so I we can know when to unpin 1.20.0 from our systems.

Also, please improve your release notes.

dh024 commented 2 years ago

@jdecaron You misunderstand the information presented here. The issue is closed because a fix has been implemented in the master code, which will be used in a future release. If you have suggestions about things like release notes, the community forums may be a better place to post such comments.

jdecaron commented 2 years ago

The issue is closed because a fix has been implemented in the master code

@dh024 I strongly disagree, the issue can be closed once a published build release will be available.

If you have suggestions about things like release notes, the community forums may be a better place to post such comments.

I disagree too, I think letting an official developer know that their release notes lack relevant bug fix information is a direct and clear way of communicating information according to release notes.

aptly-io commented 2 years ago

@jdecaron, I also think, like @dh024, that it is a common practise to close an issue once there's a fix in the repo, even if there's no official release made yet. Was 1.21.1 a release of this fix? I don't think so. That might be the reason it is not in the corresponding release notes. I actually started noticing the issue since 1.21.1 Anyway, I let @eliykat decide how to proceed with this issue.

eliykat commented 2 years ago

@dh024 is correct, our practice is to close issues once the fix has been merged, even if it hasn't been released yet. This fix will be released in the March release, scheduled for 17-18 March (but subject to change).

@jdecaron, have you tried the suggested workaround here, and did it work for you?

I've passed on your feedback about the release notes.

jdecaron commented 2 years ago

@eliykat thank you for your response.

our practice is to close issues once the fix has been merged, even if it hasn't been released yet. This fix will be released in the March release, scheåduled for 17-18 March (but subject to change).

I understand it's not as black and white as I made it sound so it's fine if you guys consider this solved once it hits your main branch. But keep in mind that most people consume tools via downloaded builds and package managers. So it means that if you guys don't have a continuous integration to build a new release when your main branch is updated, it means that most consumers of your tool will still have the issue unresolved until you guys publish a new release. It also means that I can't get a state update from this issue I'm subscribing since its state is already closed.

@jdecaron, have you tried the suggested workaround here, and did it work for you?

On my system it cannot be an issue with an upgrade process since this issue happens on a fresh instance. Which means there's no local data nor any previous installation of Bitwarden.

I've passed on your feedback about the release notes.

Thank you, it's not a big deal, I understand it can be time consuming. It's just that I consider release notes a common and good practice.

eliykat commented 2 years ago

Closing issues

I take your point, I suppose there are differing requirements for devs (is the fix in master) vs. users (is the fix in the release). Github encourages the former by automatically linking & closing issues, but from a user perspective I understand it's not ideal. The feedback I got about release notes was that we should be able to produce more detailed notes after some internal tooling changes (currently underway), so that should help clarify what's in what release. In the meantime, please feel free to ask if you need clarification. Our release cycle is roughly every 6 weeks.

On my system it cannot be an issue with an upgrade process since this issue happens on a fresh instance. Which means there's no local data nor any previous installation of Bitwarden.

Can you please provide the following info:

I've reopened this for now, as it's unclear whether this is fixed from the PR I merged (which only targeted migrating the old data.json).

aptly-io commented 2 years ago

@eliykat Today I briefly looked into this again on MacOS 12.2.1 with your proposed fix on cleaning this data.json. This does not work in this case. I also answer your question you listed above (the data.json dump is at the end).

BW is installed by brew (.venv) macbook.local franchan ~/dev/pwsync $ bw --version 1.21.1 (.venv) macbook.local franchan ~/dev/pwsync $ node --version v17.6.0 I use the official Bitwarden.com service. The account has an organization.

I cleaned this directory (you see it recreated according to test logging. This is a small unit test that I use in pwsync (https://github.com/aptly-io/pwsync/pulls). Each time the BW command line params are logged: one can follow what goes in and out from BW easily. Several times the test passes but also several times this unit test fails, all randomly (without a pattern).

One item is created and the test verifies this by reading the database. But the bw list returns empty. The test succeeds with 1.19.1 (I did not try with versions between 1.19.1 and 1.21.1)

(.venv) macbook.local franchan ~/dev/pwsync $ rm -rf ~/Library/Application\ Support/Bitwarden\ CLI/
(.venv) macbook.local franchan ~/dev/pwsync $ python -m pytest -s -vvv --cov=pwsync --cov-report=xml:cov.xml tests/test_bwc.py::test_create_only_title_name_secret_path || echo "FAILED"
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.9.10, pytest-7.0.1, pluggy-1.0.0 -- /Users/franchan/dev/pwsync/.venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/franchan/dev/pwsync, configfile: pytest.ini
plugins: pylama-8.3.7, mock-3.7.0, cov-3.0.0
collected 1 item                                                                                                                                                                                           

tests/test_bwc.py::test_create_only_title_name_secret_path 
---------------------------------------------------------------------------------------------- live log setup ----------------------------------------------------------------------------------------------
ENT _make_session
ENT _get_status
Could not find dir, "/Users/franchan/Library/Application Support/Bitwarden CLI"; creating it instead.
Could not find data file, "/Users/franchan/Library/Application Support/Bitwarden CLI/data.json"; creating it instead.
ENT _check_output
cmd: ['bw', '--raw', 'status'], result: b'{"serverUrl":null,"lastSync":null,"status":"unauthenticated"}'
FIN _check_output : 1s
FIN _get_status : 3s
cmd: ['bw', '--raw', 'unlock', '--passwordenv=BW_MASTER_PASSWORD']
ENT _sync
cmd: ['bw', 'sync'], result: Syncing complete.
FIN _sync : 1s
FIN _make_session : 9s
Purge vault
ENT _list_objects
ENT _check_output
cmd: ['bw', '--raw', 'list', 'items'], result: b'[{"object":"item","id":"1381cbfa-dde7-4947-b184-ae4f00e3cc30","organizationId":null,"folderId":"d5d164b4-c825-476c-bdb7-ae4f00e3ca4b","type":1,"reprompt":0,"name":"title","notes":null,"favorite":false,"login":{"uris":[],"username":"name","password":"secret","totp":null,"passwordRevisionDate":null},"collectionIds":[],"revisionDate":"2022-03-05T13:49:23.136Z"}]'
FIN _check_output : 2s
FIN _list_objects : 2s
ENT _delete_object
FIN _delete_object : 1s
ENT _list_objects
ENT _check_output
cmd: ['bw', '--raw', 'list', 'folders'], result: b'[{"object":"folder","id":"d5d164b4-c825-476c-bdb7-ae4f00e3ca4b","name":"path1/path1_1"},{"object":"folder","id":null,"name":"No Folder"}]'
FIN _check_output : 1s
FIN _list_objects : 1s
ENT _delete_object
FIN _delete_object : 1s
ENT _list_objects
ENT _check_output
cmd: ['bw', '--raw', 'list', 'items'], result: b'[]'
FIN _check_output : 2s
FIN _list_objects : 2s
ENT _list_objects
ENT _check_output
cmd: ['bw', '--raw', 'list', 'organizations'], result: b'[{"object":"organization","id":"fe075cdc-04da-4489-be91-ad68008957e3","name":"organization","status":2,"type":0,"enabled":true}]'
FIN _check_output : 1s
FIN _list_objects : 1s
ENT _list_objects
ENT _check_output
cmd: ['bw', '--raw', 'list', 'org-collections', '--organizationid', 'fe075cdc-04da-4489-be91-ad68008957e3'], result: b'[]'
FIN _check_output : 1s
FIN _list_objects : 1s
---------------------------------------------------------------------------------------------- live log call -----------------------------------------------------------------------------------------------
ENT create
ENT _prevent_duplicates
ENT _find_folder_uuid
ENT _find_uuid
ENT _list_objects
ENT _check_output
cmd: ['bw', '--raw', 'list', 'folders', '--search', 'path1/path1_1'], result: b'[]'
FIN _check_output : 1s
FIN _list_objects : 1s
FIN _find_uuid : 1s
FIN _find_folder_uuid : 1s
ENT _check_output
cmd: ['bw', '--raw', 'list', 'items', '--search', 'name', '--folderid', 'null'], result: b'[]'
FIN _check_output : 2s
FIN _prevent_duplicates : 3s
ENT _find_folder_uuid
ENT _find_uuid
ENT _list_objects
ENT _check_output
cmd: ['bw', '--raw', 'list', 'folders', '--search', 'path1/path1_1'], result: b'[]'
FIN _check_output : 1s
FIN _list_objects : 1s
ENT _create_object
ENT _check_output
cmd: ['bw', 'create', 'folder'], result: b'{"object":"folder","id":"83f3b8b6-79ac-40cb-9cef-ae4f00e40f92","name":"path1/path1_1"}'
FIN _check_output : 1s
FIN _create_object : 1s
FIN _find_uuid : 2s
FIN _find_folder_uuid : 2s
ENT _find_uuid
FIN _find_uuid : 3us
ENT _create_object
ENT _check_output
cmd: ['bw', 'create', 'item'], result: b'{"object":"item","id":"1051b588-9c97-410b-8541-ae4f00e41191","organizationId":null,"folderId":"83f3b8b6-79ac-40cb-9cef-ae4f00e40f92","type":1,"reprompt":0,"name":"title","notes":null,"favorite":false,"login":{"uris":[],"username":"name","password":"secret","totp":null,"passwordRevisionDate":null},"revisionDate":"2022-03-05T13:50:22.340Z"}'
FIN _check_output : 1s
FIN _create_object : 1s
ENT _sync
cmd: ['bw', 'sync'], result: Syncing complete.
FIN _sync : 2s
ENT _object2item
ENT _get_object_name
ENT _get_object
ENT _check_output
cmd: ['bw', '--raw', 'get', 'folder', '83f3b8b6-79ac-40cb-9cef-ae4f00e40f92'], result: b'{"object":"folder","id":"83f3b8b6-79ac-40cb-9cef-ae4f00e40f92","name":"path1/path1_1"}'
FIN _check_output : 1s
FIN _get_object : 1s
FIN _get_object_name : 1s
ENT _get_object_name
FIN _get_object_name : 0us
FIN _object2item : 1s
FIN create : 11s
ENT read
ENT _list_objects
ENT _check_output
cmd: ['bw', '--raw', 'list', 'items'], result: b'[]'
FIN _check_output : 1s
FIN _list_objects : 1s
FIN read : 1s
FAILED
-------------------------------------------------------------------------------------------- live log teardown ---------------------------------------------------------------------------------------------
ENT logout
logout!
FIN logout : 3s

================================================================================================= FAILURES =================================================================================================
_________________________________________________________________________________ test_create_only_title_name_secret_path __________________________________________________________________________________

bwc = <pwsync.bw_cli_wrapper.BitwardenClientWrapper object at 0x109a4fe20>

    def test_create_only_title_name_secret_path(bwc):
        folder = "path1/path1_1"
        i = bwc.create(PwsItem(TITLE, NAME, SECRET, folder))
        assert TITLE == i.title
        assert NAME == i.name
        assert SECRET == i.secret
        assert folder == i.folder
        assert i.note is None
        assert i.url is None
>       assert len(bwc.read()) == 1
E       assert 0 == 1
E         +0
E         -1

tests/test_bwc.py:116: AssertionError
-------------------------------------------------------------------------------------------- Captured log setup --------------------------------------------------------------------------------------------
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _make_session
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _get_status
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _check_output
DEBUG    PWSYNC:bw_cli_wrapper.py:194 cmd: ['bw', '--raw', 'status'], result: b'{"serverUrl":null,"lastSync":null,"status":"unauthenticated"}'
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _check_output : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _get_status : 3s
DEBUG    PWSYNC:bw_cli_wrapper.py:250 cmd: ['bw', '--raw', 'unlock', '--passwordenv=BW_MASTER_PASSWORD']
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _sync
DEBUG    PWSYNC:bw_cli_wrapper.py:213 cmd: ['bw', 'sync'], result: Syncing complete.
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _sync : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _make_session : 9s
DEBUG    pwsync:test_bwc.py:41 Purge vault
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _list_objects
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _check_output
DEBUG    PWSYNC:bw_cli_wrapper.py:194 cmd: ['bw', '--raw', 'list', 'items'], result: b'[{"object":"item","id":"1381cbfa-dde7-4947-b184-ae4f00e3cc30","organizationId":null,"folderId":"d5d164b4-c825-476c-bdb7-ae4f00e3ca4b","type":1,"reprompt":0,"name":"title","notes":null,"favorite":false,"login":{"uris":[],"username":"name","password":"secret","totp":null,"passwordRevisionDate":null},"collectionIds":[],"revisionDate":"2022-03-05T13:49:23.136Z"}]'
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _check_output : 2s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _list_objects : 2s
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _delete_object
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _delete_object : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _list_objects
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _check_output
DEBUG    PWSYNC:bw_cli_wrapper.py:194 cmd: ['bw', '--raw', 'list', 'folders'], result: b'[{"object":"folder","id":"d5d164b4-c825-476c-bdb7-ae4f00e3ca4b","name":"path1/path1_1"},{"object":"folder","id":null,"name":"No Folder"}]'
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _check_output : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _list_objects : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _delete_object
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _delete_object : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _list_objects
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _check_output
DEBUG    PWSYNC:bw_cli_wrapper.py:194 cmd: ['bw', '--raw', 'list', 'items'], result: b'[]'
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _check_output : 2s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _list_objects : 2s
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _list_objects
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _check_output
DEBUG    PWSYNC:bw_cli_wrapper.py:194 cmd: ['bw', '--raw', 'list', 'organizations'], result: b'[{"object":"organization","id":"fe075cdc-04da-4489-be91-ad68008957e3","name":"organization","status":2,"type":0,"enabled":true}]'
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _check_output : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _list_objects : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _list_objects
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _check_output
DEBUG    PWSYNC:bw_cli_wrapper.py:194 cmd: ['bw', '--raw', 'list', 'org-collections', '--organizationid', 'fe075cdc-04da-4489-be91-ad68008957e3'], result: b'[]'
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _check_output : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _list_objects : 1s
-------------------------------------------------------------------------------------------- Captured log call ---------------------------------------------------------------------------------------------
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT create
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _prevent_duplicates
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _find_folder_uuid
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _find_uuid
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _list_objects
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _check_output
DEBUG    PWSYNC:bw_cli_wrapper.py:194 cmd: ['bw', '--raw', 'list', 'folders', '--search', 'path1/path1_1'], result: b'[]'
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _check_output : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _list_objects : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _find_uuid : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _find_folder_uuid : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _check_output
DEBUG    PWSYNC:bw_cli_wrapper.py:194 cmd: ['bw', '--raw', 'list', 'items', '--search', 'name', '--folderid', 'null'], result: b'[]'
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _check_output : 2s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _prevent_duplicates : 3s
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _find_folder_uuid
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _find_uuid
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _list_objects
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _check_output
DEBUG    PWSYNC:bw_cli_wrapper.py:194 cmd: ['bw', '--raw', 'list', 'folders', '--search', 'path1/path1_1'], result: b'[]'
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _check_output : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _list_objects : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _create_object
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _check_output
DEBUG    PWSYNC:bw_cli_wrapper.py:194 cmd: ['bw', 'create', 'folder'], result: b'{"object":"folder","id":"83f3b8b6-79ac-40cb-9cef-ae4f00e40f92","name":"path1/path1_1"}'
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _check_output : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _create_object : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _find_uuid : 2s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _find_folder_uuid : 2s
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _find_uuid
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _find_uuid : 3us
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _create_object
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _check_output
DEBUG    PWSYNC:bw_cli_wrapper.py:194 cmd: ['bw', 'create', 'item'], result: b'{"object":"item","id":"1051b588-9c97-410b-8541-ae4f00e41191","organizationId":null,"folderId":"83f3b8b6-79ac-40cb-9cef-ae4f00e40f92","type":1,"reprompt":0,"name":"title","notes":null,"favorite":false,"login":{"uris":[],"username":"name","password":"secret","totp":null,"passwordRevisionDate":null},"revisionDate":"2022-03-05T13:50:22.340Z"}'
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _check_output : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _create_object : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _sync
DEBUG    PWSYNC:bw_cli_wrapper.py:213 cmd: ['bw', 'sync'], result: Syncing complete.
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _sync : 2s
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _object2item
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _get_object_name
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _get_object
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _check_output
DEBUG    PWSYNC:bw_cli_wrapper.py:194 cmd: ['bw', '--raw', 'get', 'folder', '83f3b8b6-79ac-40cb-9cef-ae4f00e40f92'], result: b'{"object":"folder","id":"83f3b8b6-79ac-40cb-9cef-ae4f00e40f92","name":"path1/path1_1"}'
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _check_output : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _get_object : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _get_object_name : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _get_object_name
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _get_object_name : 0us
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _object2item : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN create : 11s
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT read
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _list_objects
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT _check_output
DEBUG    PWSYNC:bw_cli_wrapper.py:194 cmd: ['bw', '--raw', 'list', 'items'], result: b'[]'
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _check_output : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN _list_objects : 1s
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN read : 1s
------------------------------------------------------------------------------------------ Captured log teardown -------------------------------------------------------------------------------------------
DEBUG    PWSYNC:bw_cli_wrapper.py:134 ENT logout
INFO     pwsync:bw_cli_wrapper.py:473 logout!
DEBUG    PWSYNC:bw_cli_wrapper.py:147 FIN logout : 3s
============================================================================================= warnings summary =============================================================================================
.venv/lib/python3.9/site-packages/construct/core.py:3
  /Users/franchan/dev/pwsync/.venv/lib/python3.9/site-packages/construct/core.py:3: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import struct, io, binascii, itertools, collections, pickle, sys, os, tempfile, hashlib, importlib, imp

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

---------- coverage: platform darwin, python 3.9.10-final-0 ----------
Coverage XML written to file cov.xml

========================================================================================= short test summary info ==========================================================================================
FAILED tests/test_bwc.py::test_create_only_title_name_secret_path - assert 0 == 1
====================================================================================== 1 failed, 1 warning in 38.60s =======================================================================================
FAILED
(.venv) macbook.local franchan ~/dev/pwsync $ bw --version
1.21.1
(.venv) macbook.local franchan ~/dev/pwsync $ node --version
v17.6.0
(.venv) macbook.local franchan ~/dev/pwsync $ 

(.venv) macbook.local franchan ~/dev/pwsync $ cat ~/Library/Application\ Support/Bitwarden\ CLI/data.json 
{
  "global": {
    "locale": "en",
    "theme": "system",
    "window": {},
    "stateVersion": 4,
    "environmentUrls": {
      "base": null,
      "api": null,
      "identity": null,
      "icons": null,
      "notifications": null,
      "events": null,
      "webVault": null,
      "keyConnector": null
    },
    "installedVersion": "1.21.1"
  },
  "authenticatedAccounts": [
    "xxxxxxxx-yyyy-zzzz-qqqq-wwwwwwwwwwwwwwww",
    "xxxxxxxx-yyyy-zzzz-qqqq-wwwwwwwwwwwwwwww"
  ],
  "appId": "aaaaaaa-yyyy-zzzz-qqqq-wwwwwwwwwwwwwwww",
  "xxxxxxxx-yyyy-zzzz-qqqq-wwwwwwwwwwwwwwww": {
    "data": {
      "ciphers": {},
      "folders": {},
      "sends": {},
      "collections": {},
      "policies": {},
      "passwordGenerationHistory": {}
    },
    "keys": {
      "cryptoSymmetricKey": {},
      "organizationKeys": {},
      "providerKeys": {},
      "privateKey": {}
    },
    "profile": {},
    "settings": {
      "biometricLocked": null,
      "environmentUrls": {
        "base": null,
        "api": null,
        "identity": null,
        "icons": null,
        "notifications": null,
        "events": null,
        "webVault": null,
        "keyConnector": null
      },
      "pinProtected": {
        "decrypted": null,
        "encrypted": null
      },
      "protectedPin": null,
      "settings": null,
      "vaultTimeoutAction": "lock"
    },
    "tokens": {}
  },
  "accountActivity": {
    "xxxxxxxx-yyyy-zzzz-qqqq-wwwwwwwwwwwwwwww": null
  },
  "activeUserId": null
jdecaron commented 2 years ago

@eliykat

what do you mean by "fresh instance", are you spinning up virtual machines or something? Please try clearing data.json anyway (after reproducing the bug), just in case I'm missing something here and to completely rule this out.

Yes, fresh virtual machines, there's no upgrade or any sort of modification of the CLI when this bug happens.

what's your install method?

npm install -g @bitwarden/cli but until you guys fix the CLI I'm pinning it with npm install -g @bitwarden/cli@1.20.0

what's your OS?

Updated and fresh Ubuntu 20.04 image from AWS.

self-hosted or official servers?

Official servers, paying for an Enterprise Organization tier.

does this occur when accessing organization items, or personal items, or both?

Organization items, more specifically the notes property value of an item.

after you've reproduced the bug, do you have any values in data.json in the following path: .keys.organizationKeys? (don't post them here, yes/no is fine.) Your user ID can be found under the activeUserId key in the same file.

I won't provide you this information since implies a bit too much; reverting back the orchestrator into a failed state.

eliykat commented 2 years ago

Thanks for the extra info, I'll dig into this further.

eliykat commented 2 years ago

I believe that I've reproduced this and I'm working on a fix.

Do you get the error if logging in with username + password? I only experience it when using --apikey.

aptly-io commented 2 years ago

@eliykat Sorry for my late answer. I only use --apikey (this guarantees a predictable flow of input when used in a wrapper python script around bw). I look forward for your fix!

PS I wish also the secret key would be hidden on the command line, just like the master password.

anonymous1184 commented 2 years ago

Having the same issue in Windows 10 21H2 I took a look at the data.json file after I did a logout and it looked like this:

(My actual user id was replaced with aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee)

{
  "global": {
    "locale": "en",
    "theme": "system",
    "window": {},
    "stateVersion": 2,
    "environmentUrls": {
      "base": null,
      "api": null,
      "identity": null,
      "icons": null,
      "notifications": null,
      "events": null,
      "webVault": null,
      "keyConnector": null
    },
    "installedVersion": "1.22.0"
  },
  "authenticatedAccounts": [
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
  ],
  "appId": "944ba7be-7c88-43ec-8b48-03af0df1d3d3",
  "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee": {
    "data": {
      "ciphers": {},
      "folders": {},
      "sends": {},
      "collections": {},
      "policies": {},
      "passwordGenerationHistory": {}
    },
    "keys": {
      "cryptoSymmetricKey": {},
      "organizationKeys": {},
      "providerKeys": {},
      "privateKey": {}
    },
    "profile": {},
    "settings": {
      "biometricLocked": null,
      "environmentUrls": {
        "base": null,
        "api": null,
        "identity": null,
        "icons": null,
        "notifications": null,
        "events": null,
        "webVault": null,
        "keyConnector": null
      },
      "pinProtected": {
        "decrypted": null,
        "encrypted": null
      },
      "protectedPin": null,
      "settings": null,
      "vaultTimeoutAction": "lock"
    },
    "tokens": {}
  },
  "accountActivity": {
    "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee": null
  },
  "activeUserId": null
}

I don't know if has anything to do but having so many times the same data repeated in the authenticatedAccounts is not a good sign.

Ever since the Captcha update I've been having lots of different issues before that never had one (I still keep having an empty data.json file even after successful login). If that feature introduced this bugs is worth to rollback and gradually reintroduce it given that the rollback will be transparent to the end user.

aptly-io commented 2 years ago

@eliykat Note that I sometimes log-in with my own bitwarden account, and while testing a script, I use another "test" bitwarden account. All from the same "home" directory.

aptly-io commented 2 years ago

Will there be a new release that I can try?

djsmith85 commented 2 years ago

@aptly-io This will be included in the next release.

If you would like to test this out, you could use the build artifacts attached to the build action https://github.com/bitwarden/cli/actions/runs/2074620794.

Please be aware, that this build has not been tested and may have other issues.

aptly-io commented 2 years ago

@djsmith85 @eliykat Thank you, I prefer to wait a bit until next release ...