BenjaminOddou / alfred-dashlane

🔐 Manage your Dashlane vault
MIT License
11 stars 1 forks source link

List index out of range #1

Closed Drumkruk closed 1 year ago

Drumkruk commented 1 year ago

After installing the workflow, the CLI and setting up the workflow I invoke the workflow by "pdash". I see "connecting" and then I get the message "Something went wrong" - " List index out of range".

Any idea what is happening?

Screenshot 2023-05-22 at 21 00 21
BenjaminOddou commented 1 year ago

Hello @Drumkruk, thanks for reporting this. Did you install the CLI manually or did you use the curl command ? I'll try to replicate the issue and debug it.

EDIT: Also, please make sure you have python 3 installed 😉

Drumkruk commented 1 year ago

I installed the CLI with the curl command. Also, I have python 3 installed, which is confirmed by running python3 --version. It is installed with homebrew.

BenjaminOddou commented 1 year ago

@Drumkruk I tried to reproduce without success yesterday. Could you please tell me:

Drumkruk commented 1 year ago

@BenjaminOddou macOS version: Ventura 13.2.1 / Intel Output is a json response. As far as I know I don't have another instance of dcli installed.

I have tried to uninstall and reinstall the workflow. Same result.

BenjaminOddou commented 1 year ago

@Drumkruk ok then could you provide me the Alfred logs ?

You'll need to comment the two try block in the entry.py file. This file is located in the workflow folder. You can right click on the workflow in Alfred preferences and click show in finder.

Then use the Alfred debugger. See how to use it here.

Tell me if you need more explanation.

Drumkruk commented 1 year ago

I found the entry.py, but I don't know what you mean with commenting two try block...

BenjaminOddou commented 1 year ago

@Drumkruk sorry, commenting is passing a # before the try and except statements. This will allow the script to throw the error to the Alfred debugger instead of grabbing it. Do you have a code editor (vs code, sublime text) >> this will help you commenting without breaking the code. As I can't replicate it, it's quite hard to debug on my side.

Drumkruk commented 1 year ago

@BenjaminOddou Thanks. By commenting the try and except statements I get the follow result in the debugger: [13:19:03.951] Dashlane[Script Filter] Queuing argument '(null)' [13:19:04.004] Dashlane[Script Filter] Script with argv '(null)' finished [13:19:04.013] ERROR: Dashlane[Script Filter] Code 1: File "/Users/xxx/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.8653A6B1-01EC-4837-8D2C-57D6F63BAF7A/entry.py", line 153 print(json.dumps(output)) ^ IndentationError: expected an indented block after 'if' statement on line 99

If I also comment the if statement on line 99 it returns:

[13:20:38.546] Dashlane[Script Filter] Queuing argument '(null)' [13:20:38.695] Dashlane[Script Filter] Script with argv '(null)' finished [13:20:38.706] Dashlane[Script Filter] "" [13:20:38.707] ERROR: Dashlane[Script Filter] JSON error: JSON text did not start with array or object and option to allow fragments not set. around line 1, column 0. in JSON:

BenjaminOddou commented 1 year ago

@Drumkruk I think you miss a part of the code. Did you comment the except statement and the indented block of code below ? Also you told me that using dcli password -o json, you had a json output, were you connected already to the cli ? Could you confirm me that you are using the last version of the cli using dcli -V.

Edit : here is the entry.py file that you can use : link

Drumkruk commented 1 year ago

@BenjaminOddou Thank you very much for the link. Now I have the error:

Code 1: Traceback (most recent call last):
  File "/Users/xxx/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.662D8D5C-9248-4B1C-A9BB-0CEEC36D3C40/entry.py", line 115, in <module>
    items.extend([build_json(vault_credential) for vault_credential in json.loads(output) if not (request == 'otp' and not vault_credential.get('otpSecret'))])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xxx/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.662D8D5C-9248-4B1C-A9BB-0CEEC36D3C40/entry.py", line 115, in <listcomp>
    items.extend([build_json(vault_credential) for vault_credential in json.loads(output) if not (request == 'otp' and not vault_credential.get('otpSecret'))])
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xxxx/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.662D8D5C-9248-4B1C-A9BB-0CEEC36D3C40/entry.py", line 24, in build_json
    domain = extract_domain(v_url)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xxx/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.662D8D5C-9248-4B1C-A9BB-0CEEC36D3C40/utils.py", line 19, in extract_domain
    domain = parsed_url.netloc.split('.')[-2] + '.' + parsed_url.netloc.split('.')[-1]
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
IndexError: list index out of range

edit: Could it be because I have a business account?

BenjaminOddou commented 1 year ago

@Drumkruk maybe this can play a role. Could you give me the structure of the JSON response from the dcli password -o json command ?

Did you input regular text values in the url field ?

Drumkruk commented 1 year ago

The response is all my saved passwords. It's way too many to check if every object contains a url field, but it seems to be the case. The structure is different per object.

Here is the structure for a random one:

{
"id":
"anonId":
"creationDatetime":
"lastBackupTime":
"lastUse":
"localeFormat":
"spaceId":
"autoLogin":
"autoProtected":
"checked":
"email":
"password":
"status":
"strength":
"subdomainOnly":
"title":
"url":
"useFixedUrl":
"modificationDatetime":
"numberUse"
}

The URL fields are by the browser recognized url's.

BenjaminOddou commented 1 year ago

@Drumkruk your issue should be solved with the new release v1.3.5. Could you please check ? Many thanks in advance 😄

Drumkruk commented 1 year ago

Yes! Fixed. Thank you very much for your patience.