wallabag icon indicating copy to clipboard operation
wallabag copied to clipboard

Some imported URL completely breaks template rendering due to an unserialization error

Open jangxx opened this issue 7 months ago • 10 comments

Environment

  • Version: 2.6.12
  • Installation: docker image
  • PHP version: 8.1.27 (from running php -v in the docker container)
  • OS: Linux
  • Database: PostgreSQL
  • Parameters:
My app/config/parameters.yml is:
parameters:
  database_driver: pdo_pgsql
  database_host: db
  database_port: 5432
  database_name: wallabag
  database_user: wallabag
  database_password: wallaroot
  database_path: '%kernel.project_dir%/data/db/wallabag.sqlite'
  database_table_prefix: wallabag_
  database_socket: null
  database_charset: utf8
  domain_name: # redacted
  server_name: # redacted
  mailer_dsn: # redacted
  locale: en
  secret: # redacted
  twofactor_sender: [email protected]
  fosuser_registration: false
  fosuser_confirmation: true
  fos_oauth_server_access_token_lifetime: 3600
  fos_oauth_server_refresh_token_lifetime: 1209600
  from_email: # redacted
  rss_limit: 50
  rabbitmq_host: localhost
  rabbitmq_port: 5672
  rabbitmq_user: guest
  rabbitmq_password: guest
  rabbitmq_prefetch_count: 10
  redis_scheme: tcp
  redis_host: redis
  redis_port: 6379
  redis_path: null
  redis_password: null
  sentry_dsn: null

What steps will reproduce the bug?

I'm trying to import around 800 links from Pocket now that they're closing down. Unfortunately, while the URLs seem to import fine, I can't actually look at any of them, since opening the list of entries only shows an error message:

500: Internal Server Error
An exception has been thrown during the rendering of a template ("Could not convert database value to 'array' as an error was triggered by the unserialization: 'unserialize(): Error at offset 695 of 1215 bytes'").

error screenshot

Looking at the log output, I can't see which URL is exactly the culprit, but looking at the prod.log file, the error does produce the log entry:

[2025-05-22T22:03:41.337590+00:00] request.CRITICAL: Uncaught PHP Exception Twig\Error\RuntimeError: "An exception has been thrown during the rendering of a template ("Could not convert database value to 'array' as an error was triggered by the unserialization: 'unserialize(): Error at offset 695 of 1215 bytes'")." at /var/www/wallabag/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig line 81 {"exception":"[object] (Twig\\Error\\RuntimeError(code: 0): An exception has been thrown during the rendering of a template (\"Could not convert database value to 'array' as an error was triggered by the unserialization: 'unserialize(): Error at offset 695 of 1215 bytes'\"). at /var/www/wallabag/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig:81)\n[previous exception] [object] (Doctrine\\DBAL\\Types\\ConversionException(code: 0): Could not convert database value to 'array' as an error was triggered by the unserialization: 'unserialize(): Error at offset 695 of 1215 bytes' at /var/www/wallabag/vendor/doctrine/dbal/src/Types/ConversionException.php:115)"} []

I would really love to switch to wallabag now that Pocket is closing down, so I hope you can fix this quickly. Thanks!

jangxx avatar May 22 '25 22:05 jangxx

Hi @jangxx,

Could you please try going to {yoururl}/2 to see if you are able to show the second page of entries? If yes, I suspect the issue is lying in the 12 most recent entries in the database. If not, the issue may be elsewhere in the entries table.

Kdecherf avatar May 23 '25 11:05 Kdecherf

Okay, that totally helped. The offending URL is this:

https://www.cgtrader.com/free-3d-models/industrial/tool/work-light-8b1b8ea9-f742-4f38-8c8e-12a2953f8ac2

if I remove it from the database manually, the page works just fine, but as soon as I add it, I get the error I wrote about.

The headers column in the database seems to contain some broken characters and then just stop in the middle of the serialized data:

a:21:{s:12:"content-type";s:24:"text/html; charset=utf-8";s:14:"content-length";s:6:"198530";s:10:"connection";s:10:"keep-alive";s:4:"date";s:29:"Fri, 23 May 2025 13:21:31 GMT";s:25:"strict-transport-security";s:35:"max-age=31536000; includeSubdomains";s:6:"server";s:5:"nginx";s:4:"vary";s:23:"Accept-Encoding, Origin";s:15:"x-frame-options";s:8:"ALLOWALL";s:4:"link";s:178:"<https://assets.cgtrader.com/assets/critical_path/free_fast_products.critical-741178e063a3f38021be5e12ce65b5ce0aea24bc18a7c2ec9d2c7b6d3430c525.css>; rel=preload; as=style; nopush";s:4:"etag";s:36:"W/"7d4f2205f4438a5b771b5c310bbf4eed"";s:13:"cache-control";s:35:"max-age=0, private, must-revalidate";s:10:"set-cookie";s:1026:"ahoy_visitor=7c290f93-4071-4738-83a0-4d11d287fff6; domain=www.cgtrader.com; path=/; expires=Sun, 23 May 2027 13:21:31 GMT; SameSite=Lax, ahoy_visit=1cdaa7a3-9ce8-4ead-892d-5668a6870897; domain=www.cgtrader.com; path=/; expires=Fri, 23 May 2025 15:21:31 GMT; SameSite=Lax, sale_off_visible=false; path=/; SameSite=Lax, seo_banner_visible=true; path=/; SameSite=Lax, _cgtrader_cookies_check=true; path=/; expires=Tue, 23 May 2045 13:21:31 GMT; SameSite=Lax, _cgtrader_98e316={	:page_viewsi:visitsi:total_timei

No idea why this is happening, but this is the exact problem I am facing.

jangxx avatar May 23 '25 13:05 jangxx

@jangxx great that you found the offending entry.

I'll try to check if I am able to reproduce the issue on my side

Kdecherf avatar May 23 '25 14:05 Kdecherf

I'm not a dev and I'm too afraid to try this myself because I don't know how to get rid of a faulty article in my database.

I've written a configuration for this domain that pulls the relevant content from the page and removes the unattractive parts.

I have no idea if this will solve your problem by coincidence (!). Would you please try this and post the result?

Copy cgtrader.com.txt to vendor/j0ker/graby-site-config of your wallabag installation. Clear cache and try to fetch this article again (not importing from Pocket)

Do you prefer to keep or remove the comments and ratings section on this domain?

HolgerAusB avatar May 23 '25 14:05 HolgerAusB

I added the file to the respective folder and restarted (not recreated!) the container. No idea if that clears the cache or not, but the problem still persists. I have no idea how to clear the cache tbh, since I've installed wallabag for the first time yesterday and don't really know anything about it yet.

Edit: and regarding this

Do you prefer to keep or remove the comments and ratings section on this domain?

it's all the same to me, since all I need is a cross-platform bookmark manager. I've never used the reader view on Pocket either, so as far as I'm concerned the page wouldn't need to get scraped at all.

jangxx avatar May 23 '25 15:05 jangxx

If you don't need the content, you can do something weird: stop the internet connection (for wallabag server), add the URL to wallabag (you will get an error instead of an article), change the title, and done ;-)

Of course, the bug needs to be found and fixed by the devs anyway, because other domains may have the same problem.

HolgerAusB avatar May 23 '25 16:05 HolgerAusB

The server is hosted on a cloud instance, so I can't just stop the internet connection to it, especially since it runs a bunch of other things as well. Also this is not a good solution either way - I can't switch to a bookmark manager that can break at any time just by adding a URL to it.

jangxx avatar May 23 '25 16:05 jangxx

I am getting this error now lately, which has made Wallabag unusable. It arbitrary becomes corrupted after having added a URL. I have to delete all the entries before being able to use Wallabag again.

I am not importing a large amount of URLs. I am using it on a daily basis using wallabagit in firefox most of the time.

BabakFarshchian avatar Jul 18 '25 09:07 BabakFarshchian

Hello @BabakFarshchian, would you be able to share the offending entry?

Kdecherf avatar Jul 18 '25 13:07 Kdecherf

Hi @Kdecherf . I tried to delete the URLs I had registered, one by one starting from the newest one. I ended up deleting all the URLs and I still had the same error message (with different numbers in the message).

This was the third time in a short time. Previous errors also required deleting all the URLs, but I could at least start using the app once the URLs were removed. This time it did not help to delete everything either.

I have decided to put aside wallabag for a while and have uninstalled it from my hosting service. I love the app and have used it for 3-4 years without problems. But being it now so unreliable makes it difficult to use for me :-)

BabakFarshchian avatar Jul 23 '25 13:07 BabakFarshchian