bachya / lp-vault-manager

An Alfred 2 workflow to interact with a LastPass vault.
121 stars 13 forks source link

lpvs KeyError: u'hostname' #18

Open bradleyhurley opened 8 years ago

bradleyhurley commented 8 years ago

[ERROR: alfred.workflow.input.scriptfilter] Code 1: 22:26:56 workflow.py:1386 DEBUG Reading settings from/Users/brad.hurley/Library/Application Support/Alfred 2/Workflow Data/com.bachya.lpvm/settings.json... 22:26:56 workflow.py:1960 DEBUG Workflow version : 4.2.0 22:26:56 lpvs_query.py:30 DEBUG Query arguments: [u'search-vault-for-query', u't'] 22:26:56 lpvs_query.py:38 DEBUG Parsed command: search-vault-for-query 22:26:56 lpvs_query.py:39 DEBUG Parsed argument: t 22:26:56 lpvs_query.py:40 DEBUG Parsed delimiter: > 22:26:56 lpvs_query.py:41 DEBUG Parsed query: search-vault-for-query t 22:26:56 lpvs_query.py:53 DEBUG Executing command: search-vault-for-query 22:26:56 workflow.py:1609 DEBUG Loading cached data from : /Users/brad.hurley/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.bachya.lpvm/vault_items.cpickle 22:26:56 workflow.py:1978 ERROR u'hostname' Traceback (most recent call last): File "/Users/brad.hurley/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.6446AD3B-324D-403F-B0D8-7BE4434ECE5C/workflow/workflow.py", line 1971, in run func(self) File "lpvs_query.py", line 55, in main output_query_vault_results(ap) File "lpvs_query.py", line 151, in output_query_vault_results results = util.search_vault_for_query(ap.arg) File "/Users/brad.hurley/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.6446AD3B-324D-403F-B0D8-7BE4434ECE5C/utilities.py", line 221, in search_vault_for_query match_on=MATCH_ALL ^ MATCH_ALLCHARS File "/Users/brad.hurley/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.6446AD3B-324D-403F-B0D8-7BE4434ECE5C/workflow/workflow.py", line 1791, in filter value = key(item).strip() File "/Users/brad.hurley/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.6446AD3B-324D-403F-B0D8-7BE4434ECE5C/utilities.py", line 199, in search_item_fields elements.append(item['hostname']) KeyError: u'hostname' 22:26:56 workflow.py:1996 DEBUG Workflow finished in 0.019 seconds.

When I run lpass ls the results look as I would expect.

I added a debug statement to utilities.search_item_fields and all of the urls are populated, but the item list does not contain any hostnames.

bradleyhurley commented 8 years ago

In the event that someone else has this issue it is caused by upgrading lastpass-cli to version 0.9.0.

You can modify /usr/local/Library/Formula/lastpass-cli.rb to brew install version 0.8.1.

Updare the version URL and the sha256 values. class LastpassCli < Formula desc "LastPass command-line interface tool" homepage "https://github.com/lastpass/lastpass-cli" url "https://github.com/lastpass/lastpass-cli/archive/v0.8.1.tar.gz" sha256 "b57ee688d9e9877f25a0ef566cff9a8c364f28e26c54b3c11eb338468cddfeb2" head "https://github.com/lastpass/lastpass-cli.git"

bottle do cellar :any sha256 "b57ee688d9e9877f25a0ef566cff9a8c364f28e26c54b3c11eb338468cddfeb2" => :el_capitan sha256 "e8ca9db904d637852830910ff8905c4be206a7b15ebbf04c0e1ead5073ea9642" => :yosemite sha256 "bf2a47f74b67df21875b3a01e87acad4d5e3d69ccff79987d73ca56e8020134a" => :mavericks end

carterdanko commented 8 years ago

I am still having this issue after downgrading to cli 0.8.1. Not sure if it is environment related or python issues or what.

carterdanko commented 8 years ago

I was having the issue above running on cli 0.8.1 and was getting the stacktrace.

[ERROR: alfred.workflow.input.scriptfilter] Code 1: 22:49:35 workflow.py:1386 DEBUG Reading settings from/Users/carterdanko/Library/Application Support/Alfred 2/Workflow Data/com.bachya.lpvm/settings.json... 22:49:36 workflow.py:1960 DEBUG Workflow version : 4.2.0 22:49:36 lpvs_query.py:30 DEBUG Query arguments: [u'search-vault-for-query', u'g'] 22:49:36 lpvs_query.py:38 DEBUG Parsed command: search-vault-for-query 22:49:36 lpvs_query.py:39 DEBUG Parsed argument: g 22:49:36 lpvs_query.py:40 DEBUG Parsed delimiter: > 22:49:36 lpvs_query.py:41 DEBUG Parsed query: search-vault-for-query g 22:49:36 lpvs_query.py:53 DEBUG Executing command: search-vault-for-query 22:49:36 workflow.py:1609 DEBUG Loading cached data from : /Users/carterdanko/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.bachya.lpvm/vault_items.cpickle 22:49:36 workflow.py:1978 ERROR u'hostname' Traceback (most recent call last): File "/Users/carterdanko/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.DFD57440-F2AF-4CF3-99E1-2F478E7C5493/workflow/workflow.py", line 1971, in run func(self) File "lpvs_query.py", line 55, in main output_query_vault_results(ap) File "lpvs_query.py", line 151, in output_query_vault_results results = util.search_vault_for_query(ap.arg) File "/Users/carterdanko/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.DFD57440-F2AF-4CF3-99E1-2F478E7C5493/utilities.py", line 218, in search_vault_for_query match_on=MATCH_ALL ^ MATCH_ALLCHARS File "/Users/carterdanko/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.DFD57440-F2AF-4CF3-99E1-2F478E7C5493/workflow/workflow.py", line 1791, in filter value = key(item).strip() File "/Users/carterdanko/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.DFD57440-F2AF-4CF3-99E1-2F478E7C5493/utilities.py", line 196, in search_item_fields elements.append(item['hostname']) KeyError: u'hostname' 22:49:36 workflow.py:1996 DEBUG Workflow finished in 0.046 seconds.

I ended up tinkering with the code a little and eventually got a 'Cannot set attribute' error with both the args that are being passed in so 'search-vault-for-query '

I deleted the workflow from alfred, and reimported it. When I did, i ran python update.py lpvs was working once again since the downgrade to 0.8.1.

I should also mention that I am running on el capitan 10.11.4 with python 2.7.11.

I have no idea what was going on or what had changed, but at least it works now.

RowanKaag commented 8 years ago

Would be great if the developer would add support for the new lastpass-cli binary.

bradleyhurley commented 8 years ago

It's not as feature rich, but @carterdanko created an alternative. https://github.com/carterdanko/lastpass-vault-search

crikeymiles2 commented 7 years ago

Trying to follow Bradley's solution above, but I'm on Sierra. Any clues on what the hash to add for sierra should be?

bottle do cellar :any sha256 "???" => :sierra ... end

Thanks!

carterdanko commented 7 years ago

@crikeymiles2 When you do a brew info lastpass-cli you can see where it is pulling the rb file with the hashes so you should be able to pull the hash from there which is: https://github.com/Homebrew/homebrew-core/blob/master/Formula/lastpass-cli.rb

I'm not sure on other support though for this workflow. The one Brad and I wrote works with sierra I know and is less feature rich than this one, but works with current lasspass-cli/alfredv3/sierra.

AVancans commented 7 years ago

This solved my issue:

  1. Find your lastpass workflow directory (eg. ~/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.XXXXXXXXXXXX)
  2. Find all references of hostname in .py files (make sure it's hostname as in map key name)
  3. Replace with name
  4. Run python -m compileall . (you must have python installed)
  5. Done.

It seems lastpass cli changed their export content and it does not contain host column anymore.

ianmartorell commented 7 years ago

Thanks @SharkyLV! That fixed if for me. Replacing all instances of 'hostname' didn't work though, it gave me the error lpvs KeyError: u'name'. I had to replace all instances of hostname (without the quotes) for name and that did it.

ratelgogo commented 7 years ago

@SharkyLV Thanks! It works for me!

cybermike844 commented 7 years ago

@SharkyLV That worked for me as well, thank you soo much!!

levibostian commented 6 years ago

Bummer. I tried @SharkyLV's suggestion with no luck. Now I am getting the error lpvs KeyError: u'name' instead of lpvs KeyError: u'hostname'.

Thanks for the suggestion though!

On the latest version of lp-vault-manager (I installed it 10 minutes ago) and the latest version of lp-cli from homebrew (I also installed it 10 minutes ago).

ianmartorell commented 6 years ago

@levibostian replace all instances of hostname with name (no quotes), that should fix it.

levibostian commented 6 years ago

...I feel stupid. I read your comment earlier and didn't make the connection. Sorry about that. Thank you! I will give that a shot.

ianmartorell commented 6 years ago

No problem :). I probably could have written that a bit more clearly to be honest...

levibostian commented 6 years ago

I went through the code and replaced all instances of hostname with name but only the instances of the word not in quotes (which was mostly a collection of variable names so I am not sure how that solution is supposed to work?).

Now I am back at KeyError: u'hostname'.

Does anyone have a fork of the repo with this fix implemented that others can use and benefit from and we can get a fix merged in?

I appreciate everyone's help here. Wish I could be of more help if I could get it figured out on my own machine šŸ¤”.

ianmartorell commented 6 years ago

Ah well, in that case I can't help you, I haven't used this in months šŸ™„

bradleyhurley commented 6 years ago

Here is a re-write of the last pass vault search that I have been using daily without issues:

https://github.com/carterdanko/lastpass-vault-search

1yndonn3u commented 6 years ago

This solved my issue:

  1. Find your lastpass workflow directory (eg. ~/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.XXXXXXXXXXXX)
  2. Find all references of hostname in .py files (make sure it's hostname as in map key name)
  3. Replace with name
  4. Run python -m compileall . (you must have python installed)
  5. Done.

It seems lastpass cli changed their export content and it does not contain host column anymore.

Good! it is also work for alfred3.