sissbruecker / linkding

Self-hosted bookmark manager that is designed be to be minimal, fast, and easy to set up using Docker.
https://linkding.link/
MIT License
6.33k stars 299 forks source link

Failed to create HTML snapshot if url too long #681

Closed XiaoXuxxxx closed 5 months ago

XiaoXuxxxx commented 6 months ago

The version I found the problem with is 1.27.0 plus

I found the problem when creating a snapshot for the webpage when the URL is too long. so I try to run the app in my local.

For example, if the URL that will be snapshotted is

https://github.com/sissbruecker/linkding?url=000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

the error will be

INFO 2024-04-03 14:40:04,816 tasks: Create HTML snapshot for bookmark. url=https://github.com/sissbruecker/linkding?url=000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
ENAMETOOLONG: name too long, open '/workspaces/linkding/data/assets/snapshot_2024-04-03_144004_https___github.com_sissbruecker_linkding_url_000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.html.gz.tmp' URL: https://github.com/sissbruecker/linkding?url=000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Stack: Error: ENAMETOOLONG: name too long, open '/workspaces/linkding/data/assets/snapshot_2024-04-03_144004_https___github.com_sissbruecker_linkding_url_000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.html.gz.tmp'
ERROR 2024-04-03 14:40:14,904 tasks: Failed to create HTML snapshot for bookmark. url=https://github.com/sissbruecker/linkding?url=000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Traceback (most recent call last):
  File "/workspaces/linkding/bookmarks/services/tasks.py", line 248, in _create_html_snapshot_task
    singlefile.create_snapshot(asset.bookmark.url, filepath)
  File "/workspaces/linkding/bookmarks/services/singlefile.py", line 25, in create_snapshot
    raise SingeFileError("Failed to create snapshot")
bookmarks.services.singlefile.SingeFileError: Failed to create snapshot

From the log above, the cause is the length of the snapshot file's name exceeds the OS limit.

sissbruecker commented 6 months ago

Looks like the URL should be truncated to some reasonable length here: https://github.com/sissbruecker/linkding/blob/bb6c5ca29e3b66a70c2ff1751ea6183c7011d4ae/bookmarks/services/tasks.py#L228-L230