iv-org / invidious

Invidious is an alternative front-end to YouTube
https://invidious.io
GNU Affero General Public License v3.0
16.08k stars 1.78k forks source link

[Bug] Unable to add new subscriptions/import, Exception: Nil assertion failed (NilAssertionError) #3743

Closed tempname1024 closed 1 year ago

tempname1024 commented 1 year ago

Describe the bug I'm running into an assertion error which began after a recent system/dependency upgrade and re-compilation of invidious on Alpine against 961cae2b9a1e1dd780e3f92d55bbc7381b39ffe1. RefreshChannelsJob started to fail with Nil assertion failed, and new subscriptions were unable to be added.

Video playback, account creation, and search are unaffected.

Logs (creating a new subscription)

[...]
2023-04-16 15:49:01 UTC [trace] parse_item: Parser "Parsers::RichItemRendererParser" does not apply. Cycling to the next one...
2023-04-16 15:49:01 UTC [trace] parse_item: Attempting to parse item using "Parsers::ReelItemRendererParser" (cycling...)
2023-04-16 15:49:01 UTC [trace] parse_item: Parser "Parsers::ReelItemRendererParser" does not apply. Cycling to the next one...
2023-04-16 15:49:01 UTC [trace] parse_item: Attempting to parse item using "Parsers::ItemSectionRendererParser" (cycling...)
2023-04-16 15:49:01 UTC [trace] parse_item: Parser "Parsers::ItemSectionRendererParser" does not apply. Cycling to the
next one...
2023-04-16 15:49:01 UTC [trace] parse_item: Attempting to parse item using "Parsers::ContinuationItemRendererParser" (cycling...)
2023-04-16 15:49:01 UTC [debug] parse_item: Successfully parsed via Parsers::ContinuationItemRendererParser
2023-04-16 15:49:01 UTC [trace] fetch_channel: UCl2mFZoRqjw_ELax4Yisf6w : Extracting videos from channel RSS feed
Exception: Nil assertion failed (NilAssertionError)
  from /usr/lib/crystal/core/nil.cr:108:5 in 'not_nil!'
  from src/invidious/channels/channels.cr:197:13 in 'fetch_channel'
  from src/invidious/channels/channels.cr:151:15 in 'get_channel'
  from src/invidious/routes/subscriptions.cr:54:9 in '->'
  from lib/kemal/src/kemal/route.cr:13:9 in '->'
  from src/invidious/helpers/handlers.cr:30:37 in 'call'
  from /usr/lib/crystal/core/http/server/handler.cr:28:7 in 'call'
  from /usr/lib/crystal/core/http/server/handler.cr:28:7 in 'call_next'
  from lib/kemal/src/kemal/filter_handler.cr:21:7 in 'call'
  from /usr/lib/crystal/core/http/server/handler.cr:28:7 in 'call'
  from /usr/lib/crystal/core/http/server/handler.cr:28:7 in 'call_next'
  from src/invidious/helpers/handlers.cr:94:12 in 'call'
  from /usr/lib/crystal/core/http/server/handler.cr:28:7 in 'call_next'
  from src/invidious/helpers/handlers.cr:151:29 in 'call'
  from /usr/lib/crystal/core/http/server/handler.cr:28:7 in 'call'
  from /usr/lib/crystal/core/http/server/handler.cr:28:7 in 'call_next'
  from src/ext/kemal_static_file_handler.cr:112:11 in 'call'
  from /usr/lib/crystal/core/http/server/handler.cr:28:7 in 'call'
  from /usr/lib/crystal/core/http/server/handler.cr:28:7 in 'call'
  from /usr/lib/crystal/core/http/server/handler.cr:28:7 in 'call'
  from /usr/lib/crystal/core/http/server/request_processor.cr:51:11 in 'process'
  from /usr/lib/crystal/core/http/server.cr:500:5 in '->'
  from /usr/lib/crystal/core/fiber.cr:146:11 in 'run'
  from ???

2023-04-16 15:49:01 UTC [info] 500 POST /subscription_ajax?action_create_subscription_to_channel=1&redirect=false&c=UCl2mFZoRqjw_ELax4Yisf6w 469.49ms

Additional context

adequacy1 commented 1 year ago

Same here, with up-to-date Arch linux.

ConnerWill commented 1 year ago

I am also having this issue. Cannot subscribe to new channels, unable to import subscriptions.

Using up-to-date Arch linux.

Here is the invidious log when trying to subscribe to a channel

2023-05-01 15:46:52 UTC [info] 404 GET /api/v1/comments/oFVTIMB0L9s?format=html&hl=en-US&thin_mode=false 58.05ms
Exception: Nil assertion failed (NilAssertionError)
  from /usr/lib/crystal/nil.cr:113:7 in 'not_nil!'
  from /usr/lib/crystal/nil.cr:109:3 in 'not_nil!'
  from src/invidious/channels/channels.cr:197:13 in 'fetch_channel'
  from src/invidious/channels/channels.cr:151:15 in 'get_channel'
  from src/invidious/routes/subscriptions.cr:54:9 in '->'
  from lib/kemal/src/kemal/route.cr:13:9 in '->'
  from src/invidious/helpers/handlers.cr:30:37 in 'call'
  from /usr/lib/crystal/http/server/handler.cr:30:7 in 'call'
  from /usr/lib/crystal/http/server/handler.cr:30:7 in 'call_next'
  from lib/kemal/src/kemal/filter_handler.cr:21:7 in 'call'
  from /usr/lib/crystal/http/server/handler.cr:30:7 in 'call'
  from /usr/lib/crystal/http/server/handler.cr:30:7 in 'call_next'
  from src/invidious/helpers/handlers.cr:94:12 in 'call'
  from /usr/lib/crystal/http/server/handler.cr:30:7 in 'call_next'
  from src/invidious/helpers/handlers.cr:151:29 in 'call'
  from /usr/lib/crystal/http/server/handler.cr:30:7 in 'call'
  from /usr/lib/crystal/http/server/handler.cr:30:7 in 'call_next'
  from src/ext/kemal_static_file_handler.cr:112:11 in 'call'
  from /usr/lib/crystal/http/server/handler.cr:30:7 in 'call'
  from /usr/lib/crystal/http/server/handler.cr:30:7 in 'call'
  from /usr/lib/crystal/http/server/handler.cr:30:7 in 'call'
  from /usr/lib/crystal/http/server/request_processor.cr:51:11 in 'handle_client'
  from /usr/lib/crystal/fiber.cr:146:11 in 'run'
  from ???

2023-05-01 15:47:21 UTC [info] 500 POST /subscription_ajax?action_create_subscription_to_channel=1&redirect=false&c=UCc-0YpRpqgA5lPTpSQ5uo-Q 162.46ms

Self hosting my own instance - https://dampsock.com

adequacy1 commented 1 year ago

ConnerWill you also have a new bug in your instance #3774

GaetanLepage commented 1 year ago

Same here, using the latest git version (2023-05-03). OS: NixOS unstable

RefreshChannelsJob: UCjKCYQ21t4GMWWDQZI2jTYg : Nil assertion failed
GaetanLepage commented 1 year ago

From my testing, it seems to be caused by the parsing of the xml channel RSS feed. In the fetch_channel function, this line that tries to fetch the videoid is at the origin of the crash.

SamantazFox commented 1 year ago

This seems to be a bug with the underlying XML library (libxml2) used by crystal. See https://github.com/crystal-lang/crystal/issues/13444. We're investigating!

adequacy1 commented 1 year ago

Built with the patch suggested by SamantazFox and GaetanLepage - everything works and subscriptions are imported. Thank you!