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

data.json doesn't populate upon login #2733

Open
anonymous1184 opened this issue Oct 9, 2021 · 10 comments · Fixed by bitwarden/cli#470
Open

data.json doesn't populate upon login #2733

anonymous1184 opened this issue Oct 9, 2021 · 10 comments · Fixed by bitwarden/cli#470
Labels
cli CLI Application help wanted

Comments

@anonymous1184
Copy link

Describe the Bug

Upon successful login data.json only holds 2 entries.

Steps To Reproduce

  1. Delete data.json
  2. Issue any command to create it
  3. Login

Expected Result

data.json with all the pertinent information.

Actual Result

A quasi-empty data.json file:

{
  "installedVersion": "1.18.1",
  "appId": "a97ae1ad-6f86-4f3d-ac8e-37a3db9ac3dc"
}

Screenshots or Videos

I only set my password in the BW_PASSWORD environment variable and issued a cls command to remove it from screen.

20211009135803

Environment

  • Windows 10 x64 21H1
  • Shell: CMD
  • Build Version: 1.18.1 (latest)

Additional Context

Of course that when passing the session in any way any command that requires it fails.

@MGibson1
Copy link
Member

I believe this to be related to bitwarden/directory-connector#41.

The fix should be extracting that fix into jslib so we can use it in CLI as well.

@anonymous1184
Copy link
Author

Right now I don't recall what were the steps, but at some point I also had just the installedVersion property. I can try and find a way to replicate if that helps.

@MGibson1
Copy link
Member

That might help confirm my suspicions, yes. If I'm right the recreation should have to do with multiple simultaneous access to data.json. Perhaps multiple CLI instances running?

@anonymous1184
Copy link
Author

I'm 100% sure no multiple instances running, the issue is easily reproducible by doing what I did in the screenshot which is literally just a login.

And here's how to reproduce the single property output I had at some point:

d:
md test
cd .\test\
Invoke-WebRequest -Uri https://github.com/bitwarden/cli/releases/download/v1.18.1/bw-windows-1.18.1.zip -OutFile bw.zip
Expand-Archive -Path .\bw.zip -DestinationPath .\
$env:BITWARDENCLI_APPDATA_DIR=".\"
.\bw.exe status
Get-Content -Path .\data.json

20211013160736

Now that one I didn't see it as an issue, but I remembered that at some point I saw only a single property in the JSON, and that is because I first check the existence of data.json and if is not there I create it (to avoid the Could not find data file, "data.json"; creating it instead. output), then I issue a bw status to grab the status and continue from there...

Anyway, the login is always successful (if proper credentials) but the data.json only contains two properties:

{
  "installedVersion": "1.18.1",
  "appId": "a97ae1ad-6f86-4f3d-ac8e-37a3db9ac3dc"
}

This screenshot is complementary to the one above to showcase the actual issue:

20211013164003

@anonymous1184
Copy link
Author

Hi @MGibson1!

This issue is little over 5 months and is still present in the current version 1.21.0 which closed this ticket (can you re-open it?).

Versions 1.19.0, 1.19.1 and 1.21.0 behave similar as the data.json has only empty/null values (latest has more fields in the JSON). In other words it doesn't contain the encrypted data.

The version 1.20.0 is a bit different as it always returns Token not found which is a bit worse as it doesn't let me log in.

Prior versions have different issues, for example version 1.17.1, 1.16.0, 1.15.1, returns:

{"response":{"error":"invalid_grant","error_description":"Auth-Email header invalid."},"statusCode":400}

And versions 1.14.0 and prior:

[object Object]

Now I'm pretty sure I'm using the proper username, password and TOTP codes as I'm pasting. For TOTP I wait until between seconds 10 to 20 and 40 to 50; that is after clock was synchronized. Turning off TOTP is not an option, I also tried a couple of times the Email code and the result is the same.

If you need any specific testing let me know, I can do it manually or script it if needed.

@anonymous1184
Copy link
Author

anonymous1184 commented Feb 15, 2022

Same story with v1.21.1

20220214162910

@eliykat eliykat reopened this Feb 15, 2022
@MGibson1
Copy link
Member

Strange. Using a file lock has fixed this problem in the past.

I see in your latest screenshot, when you log in it says Could not find data file, "D:\test\data.json"; creating it instead did you delete that file intentionally prior to running your login command?

@anonymous1184
Copy link
Author

That was because I used an empty directory, but is the same if:

  • No file (previews example).
  • A blank file is created.
  • Bitwarden creates the file.

20220216102833

@Hinton Hinton added the cli CLI Application label May 25, 2022
@Hinton Hinton transferred this issue from bitwarden/cli May 25, 2022
@realslacker
Copy link

realslacker commented Jun 16, 2022

I am having a very similar issue running 1.22.1. My data.json contains folders and organizations, but no ciphers, sends, or collections even though I have all of those in my vault. Also on the linked bug from the old CLI repo it seemed to be suggested that the problem was with using an api key, however I login with username and password.

I have tried removing the data.json to regenerate it, but the problem persists.

@anonymous1184
Copy link
Author

Like you can tell for the images I use user/password and 2FA... same story. I also tried using environment variables and the issue remains, I know is not just my PC as I've tested in 5 different installations (W7, W10, W11 PowerShell/cmd).

The issue remain, latest version always says incorrect user/password even if I have scripted the whole testing scenario. So pretty much sure I'm not making any mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli CLI Application help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants