vitorgalvao / alfred-workflows

Collection of Alfred workflows
BSD 3-Clause "New" or "Revised" License
2.44k stars 167 forks source link

Error loading bookmarks #109

Closed Nerian closed 4 years ago

Nerian commented 4 years ago

Hi,

Setup info

Description of issue

When I try to search for bookmarks I get no result This has been happening for at least the last 3 days. I tried removing and reinstalling PinPlus but the same error.

Debugger output

[09:54:24.822] Logging Started...
[09:54:26.984] PinPlus[Hotkey] Processing complete
[09:54:26.988] PinPlus[Hotkey] Passing output '' to Script Filter
[09:54:27.014] PinPlus[Script Filter] Queuing argument '(null)'
[09:54:28.200] PinPlus[Script Filter] Script with argv '(null)' finished
[09:54:28.203] ERROR: PinPlus[Script Filter] Code 1: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/json/common.rb:156:in `parse': 767: unexpected token at '{"update_time":"2020-05-26T14:31:42Z"} (JSON::ParserError)

'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/json/common.rb:156:in `parse'
    from /Users/Nerian/Dropbox/Backup/Alfred.alfredpreferences/workflows/user.workflow.BF3D4171-9A18-48DE-9DD4-3715F3F88589/pinplus.rb:104:in `synced_with_website?'
    from /Users/Nerian/Dropbox/Backup/Alfred.alfredpreferences/workflows/user.workflow.BF3D4171-9A18-48DE-9DD4-3715F3F88589/pinplus.rb:154:in `fetch_bookmarks'
    from /Users/Nerian/Dropbox/Backup/Alfred.alfredpreferences/workflows/user.workflow.BF3D4171-9A18-48DE-9DD4-3715F3F88589/pinplus.rb:147:in `show_bookmarks'
    from /Users/Nerian/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/96602DA4-920A-4617-9753-839C8A77610F:3:in `<main>'
vitorgalvao commented 4 years ago

Try deleting the cache directory: /Users/Nerian/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.vitorgalvao.alfred.pinplus

Nerian commented 4 years ago

Hi,

I tried doing that but same error.

I did some debugging and it appears that the code is failing to parse the json response.

In this line: https://github.com/vitorgalvao/alfred-workflows/blob/master/PinPlus/source/pinplus.rb#L103

JSON.parse(URI("https://api.pinboard.in/v1/posts/update?auth_token=#{grab_pinboard_token}&format=json").read)['update_time']
JSON::ParserError: 751: unexpected token at '{"update_time":"2020-05-26T14:31:42Z"}

'
    from /Users/Nerian/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/json/common.rb:156:in `parse'
    from /Users/Nerian/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/json/common.rb:156:in `parse'
    from (irb):36
    from /Users/Nerian/.rvm/rubies/ruby-2.4.2/bin/irb:11:in `<main>'
2.4.2 :014 >   puts URI("https://api.pinboard.in/v1/posts/update?auth_token=#{grab_pinboard_token}&format=json").read
{"update_time":"2020-05-26T14:31:42Z"}

 => nil
2.4.2 :015 > URI("https://api.pinboard.in/v1/posts/update?auth_token=#{grab_pinboard_token}&format=json").read
 => "{\"update_time\":\"2020-05-26T14:31:42Z\"}\n\t\n"

Which is pretty weird because this works:

2.4.2 :016 > JSON.parse "{\"update_time\":\"2020-05-26T14:31:42Z\"}\n\t\n"
 => {"update_time"=>"2020-05-26T14:31:42Z"}
vitorgalvao commented 4 years ago

Something’s going on. I haven’t touched that code in a while, it seems to be something in the API response. I’ve asked.

vitorgalvao commented 4 years ago

Found the problem, already emailed Maciej. Fix needs to be done upstream, at which point the Workflow should start working again.

Nerian commented 4 years ago

Excellent, thanks!

vitorgalvao commented 4 years ago

https://www.alfredforum.com/topic/10538-pinplus-%E2%80%94-interact-with-your-pinboard-bookmarks/page/4/?tab=comments#comment-77348