wrjlewis / notion-search-alfred-workflow

An Alfred workflow to search Notion with instant results
GNU General Public License v3.0
819 stars 43 forks source link

Keyword "Competitor" seem to break plugin #83

Closed johnathanz closed 10 months ago

johnathanz commented 1 year ago

Before reporting the issue, did you ?

Describe the bug When I query the Notion plugin with certain keywords, I get a 'NoneType' object is not subscriptable error.

Issue seem to be quite specific to the keyword "Competitor".

To Reproduce Steps to reproduce the behaviour:

  1. invoke plug in with NS <keyword>
  2. See error

Expected behaviour Would expect to see notion pages containing "Competitor"

Screenshots

2023-06-26 at 20 56 47@2x

Workflow (please complete the following information):

Additional context When I query for "competit" instead of "competitor", the right results does show up, but it seems to cap at 3 results (querying Notion itself gives about 20+ results) 2023-06-26 at 21 00 22@2x

Searching in notion: 2023-06-26 at 21 03 15@2x

wrjlewis commented 1 year ago

Hi @johnathanz

This is an interesting one and looks like a genuine bug. I'm presuming you have something in your search results that is a bit unusual and that the alfred code is not expecting.

In your normal notion search results for 'competitor' is there anything that stands out? Anything to do with the new projects and tasks feature perhaps.

The code is breaking on line 320, I think it's trying to pass through an icon url that that isn't there.

I'd guess there is a collection_view type page in your search results which does not have an icon, and the code is expecting one and trying to process, which produces the error you are seeing and stops any further results from showing.

Are you able to change the code in your 'notion.py' file? It will be stored in your alfred preferences location, there is a workflows folder. If so, let me know if changing the above, to look like this, has the right effect?

Replace line 320 with the following 3 lines: (the third line should be one tab out from the line above it, ie idented out)

iconUrl = searchResults.recordMap.get('collection').get(collectionPointerId).get('value').get('icon')
if iconUrl is not None:
    searchResultObject.icon = geticonpath(searchResultObject.id, searchResults.recordMap.get('collection').get(collectionPointerId).get('value').get('icon'))
johnathanz commented 11 months ago

Hi @wrjlewis your recommended changes fixed it.

Pages I was looking up were across both Private and Teamspaces. Within Teamspaces, we have a number of pages, tasks, projects, tables that may not have icons.

Great job on diagnosing this 👍

Thanks again!

wrjlewis commented 10 months ago

Hi @johnathanz , this has now been fixed in the above two releases 👍

Let me know if you get any more issues relating to this

Thanks

johnathanz commented 9 months ago

It's been a couple of weeks & running very well. Thanks @wrjlewis. Really appreciate your work!