sobjornstad/TiddlyRemember

403 error when trying to sync certain images

Closed this issue · 4 comments

I receive the warning below when I try to Sync from TiddlyWiki.

*** 1 warning: ***
Image 'https://thedailyshot.com/wp-content/uploads/EQ-Holding-period2109240432.png' in tiddler 
'Test note' could not be retrieved at sync time: 404 Not Found.

Although it does not prevent the image to be embedded in the Anki card, it stops the sync process asking for confirmation before continuing.

Steps to reproduce:

  1. Download an empty TW

  2. Add the TiddlyRemember plugin

  3. Install TR in Anki

  4. Create a new note with the question below

     <<rememberq "20211116114723852"
     "Test image."
     "[img[https://thedailyshot.com/wp-content/uploads/EQ-Holding-period2109240432.png]]">>
    
  5. Sync the wiki in Anki app

  6. Result: a warning is displayed

I am not sure if this is a problem or not because the image ends up in the Anki card despite the warning.

The image is still appearing because, when TR is unable to retrieve an image, it leaves the existing URL in the text of the note, so Anki is then able to retrieve it on the fly if you have a network connection. You can see this by pressing Ctrl+Shift+X while editing the field in Anki to show the HTML behind the field.

As for the actual problem, there's a bug that is masking the issue – I flubbed a copy-paste maneuver, which is causing it to say the error is a 404 when it's actually a 403. I'll have that fixed in the next version.

Since the link does work in our browsers, I'm guessing that thedailyshot.com prohibits clients that it perceives as not being a web browser (like TiddlyRemember) from retrieving images. To work around this, you can download the image and add it to your wiki, either embedded or with _canonical_uri.

Ok, so your fix will make Anki not complain anymore/complain less, or will the warning still be displayed with the correct error code 403 ?

In any case, I assume linking to external images in TiddlyRemember is not the intended use case and the recommended way to embed images is to use _canonical_uri.

No, the warning will still be displayed, just with the correct error code. TR has no way of knowing whether the 403 means you gave an invalid URL or whether the website is doing something weird as in this case, so it can't sensibly suppress the warning.

In any case, I assume linking to external images in TiddlyRemember is not the intended use case and the recommended way to embed images is to use _canonical_uri.

External images are supported and an intended use case...but I don't control external web sites, so I can't guarantee they'll work. In my experience, this kind of limitation is not common for most websites, though I guess we'll have to see if anyone else runs into it. I'm not sure exactly what they're blocking, seeing as Anki is able to retrieve it fine.

That said, if you have lots of images, I definitely would recommend using _canonical_uri, since TR will have to download every external image on every sync to check whether it's changed, which could use a lot of bandwidth and be very slow.

Closing this since there doesn't appear to be any outstanding issue (and the 403 => 404 transmutation is fixed). Please comment if there's something else you think I should be doing.