goniszewski / grimoire

Bookmark manager for the wizards šŸ§™
https://grimoire.pro
MIT License
2.11k stars 65 forks source link

Switching the category of a bookmark without a feature image causes internal error #145

Open printerboi opened 3 weeks ago

printerboi commented 3 weeks ago

Describe the bug If I add a bookmark to a page without a features image (e.g. https://valgrind.org/docs/manual/cg-manual.html), the adding of the bookmark works without problems. If I want to switch the category afterward, the application encounters an internal error.

To Reproduce Steps to reproduce the behavior:

  1. Go to root of grimore
  2. Click on 'add bookmark'
  3. Insert e.g. https://valgrind.org/docs/manual/cg-manual.html and leave uncategorized
  4. Edit the bookmark
  5. Switch category to something other than uncategorized
  6. Save
  7. See internal error

Expected behavior The category switch should redirect back to the bookmarks list without causing an error and should change the category of the bookmark

Desktop (please complete the following information):

Additional context The error log of the container running grimoire yielded the following error message:

Fetched metadata {
  url: "https://valgrind.org/docs/manual/cg-manual.html",
  domain: "valgrind.org",
  title: "Valgrind",
  description: "Official Home Page for valgrind, a suite of tools for debugging and profiling. Automatically detect memory management and threading bugs, and perform detailed profiling.  The current stable version is valgrind-3.23.0.",
  author: "",
  contentText: "5.Ā Cachegrind: a high-precision tracing profiler\nTo use this tool, specify --tool=cachegrind on the ...",
  contentHtml: "<div>\n <td>\n  <div>\n5.Ā Cachegrind: a high-precision tracing profiler\n<div>\n<p>\nTo use this tool, spe...",
  contentType: "",
  contentPublishedDate: null,
  mainImageUrl: "",
  iconUrl: "https://valgrind.org/favicon.ico",
}
61 |     return file;
62 |   }
63 |   async storeImage(url, title, ownerId, relatedEntityId) {
64 |     const storage = new Storage();
65 |     if (!url || url.length === 0) {
66 |       throw new Error("Invalid image URL");
                 ^
error: Invalid image URL
      at /app/build/server/chunks/storage.js:66:13
      at storeImage (/app/build/server/chunks/storage.js:63:20)
      at /app/build/server/entries/pages/_page.server.ts.js:127:47
61 |     return file;
62 |   }
63 |   async storeImage(url, title, ownerId, relatedEntityId) {
64 |     const storage = new Storage();
65 |     if (!url || url.length === 0) {
66 |       throw new Error("Invalid image URL");
                 ^
error: Invalid image URL
      at /app/build/server/chunks/storage.js:66:13
      at storeImage (/app/build/server/chunks/storage.js:63:20)
      at /app/build/server/entries/pages/_page.server.ts.js:127:47
61 |     return file;
62 |   }
63 |   async storeImage(url, title, ownerId, relatedEntityId) {
64 |     const storage = new Storage();
65 |     if (!url || url.length === 0) {
66 |       throw new Error("Invalid image URL");
                 ^
error: Invalid image URL
      at /app/build/server/chunks/storage.js:66:13
      at storeImage (/app/build/server/chunks/storage.js:63:20)
      at /app/build/server/entries/pages/_page.server.ts.js:127:47
63 |   async storeImage(url, title, ownerId, relatedEntityId) {
64 |     const storage = new Storage();
65 |     if (!url || url.length === 0) {
66 |       throw new Error("Invalid image URL");
67 |     }
68 |     const response = await fetch(url);
                                ^
TypeError: fetch() URL is invalid
 code: "ERR_INVALID_URL"
      at /app/build/server/chunks/storage.js:68:28
      at storeImage (/app/build/server/chunks/storage.js:63:20)
      at /app/build/server/entries/pages/_page.server.ts.js:127:47
tucker19 commented 3 weeks ago

I am also seeing this on Ubuntu/Docker. This is also an issue with Tags

breezyfasano commented 2 days ago

Just wanted to report I'm also seeing this error, but it isn't just with bookmarks without images - it is all bookmarks. This is on a fresh install on Ubuntu with Docker as well

Edit: Want to include that the bookmarks with main images that are failing are also ones that do not include an icon. It may have something to do with the fact that the updateBookmark API endpoint calls storeImage which throws a new error if either of those do not exist.