spamwax / alfred-pinboard-rs

Alfred Workflow for Pinboard (Rust)
Other
279 stars 13 forks source link

Invalid server response #1

Closed cahukS closed 6 years ago

cahukS commented 6 years ago

When I enter my Pinboard credentials, I get a notification that the credentials are successfully set but after a few seconds I get a new notification about invalid server response (invalid port number....; I can't see the entire log message; here is a screenshot on Dropbox).

spamwax commented 6 years ago

can you please run the following commands in terminal and post the output here?

./alfred-pinboard-rs config -a your_username:api_token
./alfred-pinboard-rs config update
cahukS commented 6 years ago

I get this after running ./alfred-pinboard-rs update:

{"items":[{"icon":{"path":"erroricon.icns"},"subtitle":"invalid server response: invalid port number at line 3353 column 57","title":"Error"}]}⏎

spamwax commented 6 years ago

ok, run this to see if you can actually talk to Pinboard server without using this workflow:

curl https://api.pinboard.in/v1/posts/all\?auth_token\=your_username:api_token > pins.xml

pins.xml should then contain all your bookmarks.

cahukS commented 6 years ago

The curl command works, downloaded my bookmarks.

spamwax commented 6 years ago

ok, I am guessing that there is a text encoding issue related to one of the bookmarks you have based on the "line 3353 column 57". However I am not sure why it's talking about "invalid port number" To better debug, I may need to introduce more verbose logging to code but for now, you can run this and I'll try to see where the error is happening based on what output you get:

RUST_LOG=rusty_pin=debug,alfred_pinboard_rs=debug ./alfred-pinboard-rs update

By the way, does your Pinboard user name have any non-ASCII character?

cahukS commented 6 years ago

DEBUG 2018-04-01T08:47:18Z: alfred_pinboard_rs: Parsing input arguments. DEBUG 2018-04-01T08:47:18Z: alfred_pinboard_rs: Deciding on which command branch DEBUG 2018-04-01T08:47:18Z: alfred_pinboard_rs: Starting in setup DEBUG 2018-04-01T08:47:18Z: alfred_pinboard_rs::workflow_config: Starting in setup DEBUG 2018-04-01T08:47:18Z: alfred_pinboard_rs::workflow_config: Starting in get_workflow_dirs DEBUG 2018-04-01T08:47:18Z: alfred_pinboard_rs::workflow_config: Starting in read DEBUG 2018-04-01T08:47:18Z: alfred_pinboard_rs::workflow_config: Starting in get_alfred_version DEBUG 2018-04-01T08:47:18Z: rusty_pin::pinboard: pinb::new: calling CachedData::new DEBUG 2018-04-01T08:47:18Z: rusty_pin::pinboard::cached_data: new: starting DEBUG 2018-04-01T08:47:18Z: rusty_pin::pinboard::cached_data: create_cache_dir: starting DEBUG 2018-04-01T08:47:18Z: rusty_pin::pinboard::cached_data: load_cache_data_from_file: starting DEBUG 2018-04-01T08:47:18Z: rusty_pin::pinboard::cached_data: cache_ok: starting DEBUG 2018-04-01T08:47:18Z: rusty_pin::pinboard: pinb::new: cache file missing, calling update DEBUG 2018-04-01T08:47:18Z: rusty_pin::pinboard::cached_data: update_cache: starting DEBUG 2018-04-01T08:47:18Z: rusty_pin::pinboard::api: all_pins: starting. DEBUG 2018-04-01T08:47:18Z: rusty_pin::pinboard::api: get_api_response: starting. DEBUG 2018-04-01T08:47:18Z: rusty_pin::pinboard::api: add_auth_token: starting. DEBUG 2018-04-01T08:47:39Z: alfred_pinboard_rs: Starting in show_error_alfred {"items":[{"icon":{"path":"erroricon.icns"},"subtitle":"invalid server response: invalid port number at line 3353 column 57","title":"Error"}]}

No non-ASCII character in my username.

spamwax commented 6 years ago

when you do ./alfred-pinboard-rs config -a your_username:api_token the last part should look like this: cahukS:3622E6 , i.e. user name followed by a colon : and then api token with hex number

cahukS commented 6 years ago

Yes, I'm doing it that way.

spamwax commented 6 years ago

According to the log you posted, problem happens when adding your authorization token to the url we send to Pinboard. Maybe when you were using Alfred to setup up this workflow using pa command something went wrong.

Check the settings.json file in ~/Library/Application Support/Alfred 3/Workflow Data/cc.hamid.alfred-pinboard-rs folder. There should be a key in that file named auth_token. Check its value, it should be username:token with no spaces and no-ascii characters. Mines looks like this: "auth_token":"spamwax:AEBBBFBB3BB0BBBBB"

If that looks okay and you still get the same error message, you can then fully delete these two folders and try setting up the workflow again by using pa username:token in Alfred's window. ~/Library/Application Support/Alfred 3/Workflow Data/cc.hamid.alfred-pinboard-rs ~/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/cc.hamid.alfred-pinboard-rs

cahukS commented 6 years ago

Ok, I deleted the two folders and ran the update command without setting the auth token. I got the same error - invalid port number. Is this strange?

spamwax commented 6 years ago

after you delete the folders you need to do one-time setup of the workflow. Trigger Alfred window, and in its window type pa followed by your username:token make sure there are no spaces after the token, something like this in Alfred's window: pa cahukS:0123456789ABCDEF

cahukS commented 6 years ago

What I want to say is that even if I set the token the error is the same. Perhaps Alfred doesn't read the settings JSON?

spamwax commented 6 years ago

I'd guess it is reading it but somehow your settings file is not following the required format.

Download this alfred-pinboard-rs and copy it in the workflow's folder. Then run this and see if the token that is printed in the log matches what you entered when setting up the Workflow:

RUST_LOG=rusty_pin=debug,alfred_pinboard_rs=debug ./alfred-pinboard-rs update
cahukS commented 6 years ago

What is the path for the workflow?

spamwax commented 6 years ago

actually you don't need to copy it to workflow's path. If it is in ~/Download, you can do this:

cd ~/Downloads
chmod u+x alfred-pinboard-rs
./alfred-pinboard-rs config -a your_username:api_token
RUST_LOG=rusty_pin=debug,alfred_pinboard_rs=debug ./alfred-pinboard-rs update

On my machine, the path for workflow is: ~/Dropbox/Alfred/Alfred.alfredpreferences/workflows/user.workflow.665EAB20-5141-463D-8C5A-90093EEAA756

cahukS commented 6 years ago

I think there is a progress.

DEBUG 2018-04-01T21:13:30Z: rusty_pin::pinboard: pinb::new: calling CachedData::new DEBUG 2018-04-01T21:13:30Z: rusty_pin::pinboard::cached_data: new: starting DEBUG 2018-04-01T21:13:30Z: rusty_pin::pinboard::cached_data: create_cache_dir: starting DEBUG 2018-04-01T21:13:30Z: rusty_pin::pinboard::cached_data: load_cache_data_from_file: starting DEBUG 2018-04-01T21:13:30Z: rusty_pin::pinboard::cached_data: cache_ok: starting DEBUG 2018-04-01T21:13:30Z: rusty_pin::pinboard: pinb::new: cache file missing, calling update DEBUG 2018-04-01T21:13:30Z: rusty_pin::pinboard::cached_data: update_cache: starting DEBUG 2018-04-01T21:13:30Z: rusty_pin::pinboard::api: all_pins: starting. DEBUG 2018-04-01T21:13:30Z: rusty_pin::pinboard::api: get_api_response: starting. DEBUG 2018-04-01T21:13:30Z: rusty_pin::pinboard::api: add_auth_token: starting. DEBUG 2018-04-01T21:13:30Z: rusty_pin::pinboard::api: token:username:token DEBUG 2018-04-01T21:13:30Z: rusty_pin::pinboard::api: url: "https://api.pinboard.in/v1/posts/all?format=json&auth_token=username%3token" {"items":[{"icon":{"path":"erroricon.icns"},"subtitle":"invalid server response: invalid port number at line 3353 column 57","title":"Error"}]}⏎

As you see there now two new lines after add_auth_token: starting

spamwax commented 6 years ago

It seems you are not using your actual user name and token from Pinboard. Go to your settings page on Pinboard to retrieve your authentication token and exactly use that in Alfred's window to set up this workflow. Seems you missed installation instructions on front page.

spamwax commented 6 years ago

or if I am mistaking and you modified the log before posting, then I have to work on more logging

cahukS commented 6 years ago

I modified the log before posting.

spamwax commented 6 years ago

ok, let's see what we get from this new binary. After downloading it do the same thing as above:

cd ~/Downloads
chmod u+x alfred-pinboard-rs
./alfred-pinboard-rs config -a your_username:api_token
RUST_LOG=rusty_pin=debug,alfred_pinboard_rs=debug ./alfred-pinboard-rs update

Post the output here. If you get the same error message, then run this:

 curl https://api.pinboard.in/v1/posts/all\?format\=json\&auth_token\=your_username:api_token > bookmarks.json

(don't forget to replace username/token in above with yours)

Goto to line 3353 of bookmarks.json, and if you don't mind share that line and couple of its surroundings with me. If you don't wanna share those particular bookmarks, then delete them from your Pinboard account on their website (after backing up) and see running an update would get it fixed or not.

cahukS commented 6 years ago

{"href":"http:\/\/Pico%20-%20A%20stupidly%20simple,%20blazing%20fast,%20flat%20file%20CMS.:%20http:\/\/picocms.org\/","description":"","extended":"via DuckDuckGo for iOS","meta":"e6e8a68d0648130418cc13a5284836de","hash":"7f71fe3f14cc89de8e08606b21486298","time":"2014-08-08T21:33:38Z","shared":"no","toread":"no","tags":"Sent from my iPhone"},

This is line 3353.

{"href":"http:\/\/www.tobeannounced.org\/2014\/08\/keeping-freebsd-up-to-date\/","description":"Keeping FreeBSD up-to-date | To Be Announced","extended":"","meta":"ef5f15b3c91f63582dd531e5df8ed769","hash":"4c5eb65b98748b7622b95fde9b05780e","time":"2014-08-09T12:48:41Z","shared":"no","toread":"no","tags":"freebsd unix"},

{"href":"http:\/\/oreilly.com\/catalog\/opensources\/book\/appa.html","description":"Appendix A - The Tanenbaum-Torvalds Debate","extended":"","meta":"083ed0eaf57ac959258fe97a43ca3f3c","hash":"15c9d482098e8f1fa69ae3403a5ffd43","time":"2014-08-09T12:47:53Z","shared":"no","toread":"no","tags":"linux kernel history"}

{"href":"http:\/\/statiked.com\/","description":"Statiked:Creating Static Blogs Made Easy!","extended":"","meta":"92351c11d494f44fc992dd5b100d53c4","hash":"9ecff23cab131c955fbdfed1f4f450da","time":"2014-08-08T21:15:56Z","shared":"no","toread":"no","tags":"Sent from my iPhone"}

{"href":"http:\/\/getkirby.com\/","description":"Kirby \u2013 Home","extended":"","meta":"2cd1fa3922970d56671035504dcf5491","hash":"d742d3af61b9b3c8b9d549111fbbaa3c","time":"2014-08-08T20:57:42Z","shared":"no","toread":"no","tags":"cms php"},

And a few lines surrounding it.

I deleted the original bookmark from line 3353 but the same number line still causes the error.

cahukS commented 6 years ago

Ok, everything is fixed now. I had a few bookmarks with wrong URL syntax. Deleted those bookmarks from Pinboard and now Alfred shows the bookmarks. Thank you very much for your help.

spamwax commented 6 years ago

great!