B2_Command_Line_Tool
B2_Command_Line_Tool copied to clipboard
ERRORLEVEL
We're running "b2-windows.exe" from a simple DOS shell script. Naturally, we need to be confident of the transfer to B2 and therefore must test for failure.
Here's the error we are seeing:
ERROR: Missing account data: 'NoneType' object is not subscriptable
Use: b2 authorize-account or provide auth data with "B2_APPLICATION_KEY_ID" and "B2_APPLICATION_KEY" environment variables
We were hoping the B2 credentials would persist after a bounce (ie. stored as encrypted windows credentials), but sadly, that's not the case. So after a bounce, no more credentials.
Anyway, assuming we provide the proper B2 credentials with every run (via "authorize-account"), we still need to know if the "b2-windows.exe" command failed for any reason.
Bottom line: even after the above "Missing account data" error, an "if ERRORLEVEL 1" does not detect an error.
What are we missing?
Thanks for adding the "question" tag Paweł, but I think this issue needs a "bug" tag as well since apparently no exit code it being returned after the given error.
b2 authorize-account
saves the auth key and key id in a sqlite database. For some reason in your case on the second run it cannot be read... Are you deleting it or maybe you are running it in some kind of a sandbox?
Returning an error code seems to work fine for me - all of the tests check for that code and they do pass. It seems it might be something with your environment, rather than a bug in the code.
What do you mean by "a bounce"?
Thanks for the quick response Pawel.
Since "b2-windows.exe" is self-contained, I'm not sure where the DB would be. Where should I look?
Do one of the tests include running with no credentials? If so, what's the return code?
A bounce is a server restart.
We have many tests around that area, also running it on the binary version.
It should be in your home directory, like C:\Users\Username\.b2_account_info
. Perhaps this file is being cleaned by something during restart? It works fine for me and other people, looks like an issue specific to your environment.
Perhaps together we can figure out what's causing it though? Can you see if the file is there after authorize-account
?
Sorry for the delayed response Pawel. I still haven't really had the opportunity to get back to this. I hope to in the near future.
That said, I think it may be premature to label this Issue with https://github.com/Backblaze/B2_Command_Line_Tool/labels/invalid%2Fenvironmental, unless of course that's the default for issues you can't reproduce.
BTW, I did get a chance to track down C:\Users\Username\.b2_account_info
. The problem in that case is that the EXE doesn't read credentials from there since it runs in the "SYSTEM" context.
Given that it doesn't reproduce for me and nobody else reports this, I'd argue that it's highly probable that it's somehow related to your environment.
The exe file not having any place to put the account info file is disturbing. Can you run a python snippet on this machine to try to investigate what path does it think the database should be located in the SYSTEM context?
I apologize again Pawel for my slow turnaround. Sadly, I don't have any more time for this now.
The tool may not function ideally (in my environment), but it's usable.
Thank you anyway.