giovannicoppola / AlfreDo

Alfred for Todoist
MIT License
60 stars 2 forks source link

Script Throws an Exception when Querying for Tasks Due Today #13

Closed funkeyfreak closed 3 months ago

funkeyfreak commented 8 months ago

Thank you for creating this very useful workflow. I have run into a slight complication. When querying for tasks due today, I see the following exception:

[14:54:31.232] Logging Started...
[14:54:39.568] AlfreDo[Script Filter] Queuing argument '(null)'
[14:54:44.529] AlfreDo[Script Filter] Script with argv '(null)' finished
[14:54:44.535] ERROR: AlfreDo[Script Filter] Code 1: 0 days from last update
rebuilding database ⏳...
Traceback (most recent call last):
  File "/Users/dalinwilliams/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.EB6212C1-C3CC-4726-8670-E74972D134F0/alfredo-query.py", line 421, in <module>
    main ()
  File "/Users/dalinwilliams/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.EB6212C1-C3CC-4726-8670-E74972D134F0/alfredo-query.py", line 25, in main
    checkingTime() #checking if the database needs to be rebuilt
  File "/Users/dalinwilliams/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.EB6212C1-C3CC-4726-8670-E74972D134F0/alfredo_ops.py", line 679, in checkingTime
    getTodoistData()
  File "/Users/dalinwilliams/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.EB6212C1-C3CC-4726-8670-E74972D134F0/alfredo_ops.py", line 273, in getTodoistData
    myAllProjectCounts = fetchAllActiveProjects (myData['items'],myData['projects'],myData['sections'])
  File "/Users/dalinwilliams/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.EB6212C1-C3CC-4726-8670-E74972D134F0/alfredo_ops.py", line 124, in fetchAllActiveProjects
    sectN = [x['name'] for x in mySections if x['id'] == item['section_id']][0]
IndexError: list index out of range

Would you have any insight as to the cause of this exception?

giovannicoppola commented 8 months ago

happy to help @funkeyfreak it trips while evaluating section names a couple of questions:

funkeyfreak commented 8 months ago

This error occurred when the workflow was first run. So far, none of the tasks are functional. And yes, I am using sections. They do not contain special characters. However, several projects contain brackets, parentheses, asterisks, and other symbols.

Thank you for your assistance.

giovannicoppola commented 7 months ago

@funkeyfreak yes, Todoist is now allowing special characters in the project names and I need to change the way they are handled. I will ping you when a new version is available

giovannicoppola commented 7 months ago

@funkeyfreak version 0.4 now supports spaces and most special characters in label and project names, except:

  1. both a space and a closed parenthesis in projects and labels
  2. / in projects (reserved for sections) let me know if you see any issues!
funkeyfreak commented 7 months ago

Thank you @giovannicoppola! The selected functions as indicated below are working:

Create new Todoist tasks

When typing the name of a new task, the following excption is thrown for each character entered. In this case, the execption was thrown after the character 't' was entered.

[11:03:59.930] AlfreDo[Script Filter] Queuing argument 't'
[11:04:00.108] AlfreDo[Script Filter] Script with argv 't' finished
[11:04:00.114] ERROR: AlfreDo[Script Filter] Code 1: Traceback (most recent call last):
  File "/Users/<redacted>/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.<redacted>/alfredo_ops.py", line 1147, in <module>
    main ()
  File "/Users/dalinwilliams/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.<redacted>/alfredo_ops.py", line 1143, in main
    parseNewTask (MY_INPUT)
  File "/Users/dalinwilliams/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.<redacted>/alfredo_ops.py", line 404, in parseNewTask
    section_counts,mySectionListAll, section_ParentProjects = fetchSections(allTasks,mySections,myProjects)
  File "/Users/dalinwilliams/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.<redacted>/alfredo_ops.py", line 165, in fetchSections
    sectN = [x['name'] for x in mySections if x['id'] == item['section_id']][0]
IndexError: list index out of range

Get all Todoist tasks

The following exception is thrown upon the selection of the "Get all Todoist tasks" menu option as illustrated below.

image

[11:10:20.087] AlfreDo[Script Filter] Queuing argument '(null)'
[11:10:20.264] AlfreDo[Script Filter] Script with argv '(null)' finished
[11:10:20.269] ERROR: AlfreDo[Script Filter] Code 1: 0 days from last update
Traceback (most recent call last):
  File "/Users/<redacted>/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.<redacted>/alfredo-query.py", line 515, in <module>
    main ()
  File "/Users/dalinwilliams/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.<redacted>/alfredo-query.py", line 102, in main
    project_counts,myProjectListAll = fetchProjects(toShow,myProjects,mySections)
  File "/Users/dalinwilliams/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.<redacted>/alfredo_ops.py", line 195, in fetchProjects
    sectN = [x['name'] for x in mySections if x['id'] == item['section_id']][0]
IndexError: list index out of range
giovannicoppola commented 7 months ago

yes, I think you have either a project, section, or label name with some special characters the workflow can't handle. Because it works with overdue tasks, I assume the offending projects/labels are associated with tasks with future due dates. if you are able to share the project names etc I can try to troubleshoot.

Also, when creating a new task, does it fail right after entering the keyword (default: !!!) or when you are trying to enter a project (e.g. after #), or a label (e.g. after @)? This can also help to figure out what is going on.