jellyfin / jellyfin-plugin-opensubtitles

Home Page:https://jellyfin.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG]: `System.NullReferenceException: Object reference not set to an instance of an object.`

jiriks74 opened this issue · comments

The plugin doesn't let me sign in. All I get in the UI is an endless spinner (loading animation).
While looking into logs I noticed an error

Environment

OS: Docker
Jellyfin version: 10.9.0
Plugin version: 19.2403.7.0 from unstable Repo
Host: Raspberry Pi 5
RAM: 8GB
Storage:

  • Docker - SSD
  • Media - HDD

The page was reloaded without browser cache and opened in Firefox's Private window to have no cache at all. The issue still persists

Log
[18:27:24] [ERR] [15] Jellyfin.Api.Middleware.ExceptionMiddleware: Error processing request. URL POST /Jellyfin.Plugin.OpenSubtitles/ValidateLoginInfo.

System.NullReferenceException: Object reference not set to an instance of an object.

   at Jellyfin.Plugin.OpenSubtitles.OpenSubtitlesHandler.RequestHandler.SendRequestAsync(String endpoint, HttpMethod method, Object body, Dictionary`2 headers, String apiKey, Int32 attempt, CancellationToken cancellationToken)

   at Jellyfin.Plugin.OpenSubtitles.OpenSubtitlesHandler.OpenSubtitles.LogInAsync(String username, String password, String apiKey, CancellationToken cancellationToken)

   at Jellyfin.Plugin.OpenSubtitles.API.OpenSubtitlesController.ValidateLoginInfo(LoginInfoInput body)

   at lambda_method1005(Closure, Object)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)

   at Jellyfin.Api.Middleware.ServerStartupMessageMiddleware.Invoke(HttpContext httpContext, IServerApplicationHost serverApplicationHost, ILocalizationManager localizationManager)

   at Jellyfin.Api.Middleware.WebSocketHandlerMiddleware.Invoke(HttpContext httpContext, IWebSocketManager webSocketManager)

   at Jellyfin.Api.Middleware.IPBasedAccessValidationMiddleware.Invoke(HttpContext httpContext, INetworkManager networkManager)

   at Jellyfin.Api.Middleware.LanFilteringMiddleware.Invoke(HttpContext httpContext, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager)

   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)

   at Jellyfin.Api.Middleware.QueryStringDecodingMiddleware.Invoke(HttpContext httpContext)

   at Swashbuckle.AspNetCore.ReDoc.ReDocMiddleware.Invoke(HttpContext httpContext)

   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)

   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)

   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)

   at Jellyfin.Api.Middleware.RobotsRedirectionMiddleware.Invoke(HttpContext httpContext)

   at Jellyfin.Api.Middleware.LegacyEmbyRouteRewriteMiddleware.Invoke(HttpContext httpContext)

   at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context)

   at Jellyfin.Api.Middleware.ResponseTimeMiddleware.Invoke(HttpContext context, IServerConfigurationManager serverConfigurationManager)

   at Jellyfin.Api.Middleware.ExceptionMiddleware.Invoke(HttpContext context)

Here's what the UI looks like:
image

Found more issues in the logs:

Log
[18:39:15] [ERR] [33] Jellyfin.Api.Middleware.ExceptionMiddleware: Error processing request. URL GET /Plugins/4b9ed42f-5185-48b5-9803-6ff2989014c4/Configuration.
System.InvalidOperationException: There was an error generating the XML document.
 ---> System.InvalidCastException: [A]Jellyfin.Plugin.OpenSubtitles.Configuration.PluginConfiguration cannot be cast to [B]Jellyfin.Plugin.OpenSubtitles.Configuration.PluginConfiguration. Type A originates from 'Jellyfin.Plugin.OpenSubtitles, Version=19.2403.7.0, Culture=neutral, PublicKeyToken=null' in the context '"" Emby.Server.Implementations.Plugins.PluginLoadContext #29' at location '/config/plugins/Open Subtitles_19.2403.7.0/Jellyfin.Plugin.OpenSubtitles.dll'. Type B originates from 'Jellyfin.Plugin.OpenSubtitles, Version=19.2403.7.0, Culture=neutral, PublicKeyToken=null' in the context '"" Emby.Server.Implementations.Plugins.PluginLoadContext #4' at location '/config/plugins/Open Subtitles_19.2403.7.0/Jellyfin.Plugin.OpenSubtitles.dll'.
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterPluginConfiguration.Write4_PluginConfiguration(Object o)
   at InvokeStub_XmlSerializationWriterPluginConfiguration.Write4_PluginConfiguration(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
   at Emby.Server.Implementations.Serialization.MyXmlSerializer.SerializeToWriter(Object obj, XmlWriter writer)
   at Emby.Server.Implementations.Serialization.MyXmlSerializer.SerializeToStream(Object obj, Stream stream)
   at Emby.Server.Implementations.Serialization.MyXmlSerializer.SerializeToFile(Object obj, String file)
   at MediaBrowser.Common.Plugins.BasePlugin`1.SaveConfiguration(TConfigurationType config)
   at MediaBrowser.Common.Plugins.BasePlugin`1.LoadConfiguration()
   at MediaBrowser.Common.Plugins.BasePlugin`1.get_Configuration()
   at MediaBrowser.Common.Plugins.BasePlugin`1.MediaBrowser.Common.Plugins.IHasPluginConfiguration.get_Configuration()
   at Jellyfin.Api.Controllers.PluginsController.GetPluginConfiguration(Guid pluginId)
   at lambda_method1380(Closure, Object, Object[])
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Jellyfin.Api.Middleware.ServerStartupMessageMiddleware.Invoke(HttpContext httpContext, IServerApplicationHost serverApplicationHost, ILocalizationManager localizationManager)
   at Jellyfin.Api.Middleware.WebSocketHandlerMiddleware.Invoke(HttpContext httpContext, IWebSocketManager webSocketManager)
   at Jellyfin.Api.Middleware.IPBasedAccessValidationMiddleware.Invoke(HttpContext httpContext, INetworkManager networkManager)
   at Jellyfin.Api.Middleware.LanFilteringMiddleware.Invoke(HttpContext httpContext, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Jellyfin.Api.Middleware.QueryStringDecodingMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.ReDoc.ReDocMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Jellyfin.Api.Middleware.RobotsRedirectionMiddleware.Invoke(HttpContext httpContext)
   at Jellyfin.Api.Middleware.LegacyEmbyRouteRewriteMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context)
   at Jellyfin.Api.Middleware.ResponseTimeMiddleware.Invoke(HttpContext context, IServerConfigurationManager serverConfigurationManager)
   at Jellyfin.Api.Middleware.ExceptionMiddleware.Invoke(HttpContext context)

This issue happens even after deleting the plugin config directory

EDIT: This one was solved by sudo rm configurations/Jellyfin.Plugin.OpenSubtitles.xml and reinstalling the plugin. But the main issue still persists.
EDIT2: No it wasn't.

So looking into it I checked the configuration files.

The config file was blank

<?xml version="1.0" encoding="utf-8"?>

So I copied one from the version I used for Jellyfin 10.8:

<?xml version="1.0" encoding="utf-8"?>
<PluginConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Username>uname</Username>
  <Password>pass</Password>
  <CustomApiKey>key</CustomApiKey>
  <CredentialsInvalid>false</CredentialsInvalid>

I still got xml loading errors so I added </PluginConfiguration> to the end just in case:

<?xml version="1.0" encoding="utf-8"?>
<PluginConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Username>uname</Username>
  <Password>pass</Password>
  <CustomApiKey>key</CustomApiKey>
  <CredentialsInvalid>false</CredentialsInvalid>
</PluginConfiguration>

I noticed the same happening with Kodi Sync Queue so it may be a Jellyfin issue?

There was a new Jellyfin build. Installing it didn't solve the issue (but Kodi Sync Queue works now).

I can copy the old config and append </PluginConfiguration> to it. But when I search for subtitles nothing is found and when I open setting the config file is overwritten with <?xml version="1.0" encoding="utf-8"?>.

I got the settings load by removing the file and mounting it as a volume to the docker container in read only mode. Now the plugin can't overwrite it and does load the values saved in the file if I open the plugin settings:

image

But searching for subtitles returns no results.

image

I didn't find anything in the logs about the plugin not reaching the server or other errors.

Found more issues in the logs:

Log
This issue happens even after deleting the plugin config directory

EDIT: This one was solved by sudo rm configurations/Jellyfin.Plugin.OpenSubtitles.xml and reinstalling the plugin. But the main issue still persists. EDIT2: No it wasn't.

I'm not sure what causes this, I couldn't reproduce it but its possible that some of my earlier changes in #115 fixed it already

As for searching returning no results, that is something 10.9 actually "broke", so the plugin wont work without the changes in the previously mentioned PR

Ok. I'll look into obtaining that dev version then. I sadly can't switch to stable (10.8.x) as scrubbing isn't working and the transcoding performace is noticibly worse. As I'm running it on an RPi5 it may be performance related but I've had these issues for years and Jellyfin 10.9 is way better in that regard.

As for the issue it could be something related to loading/setting the config as the file is overwritten only if I open the plugin's settings. As mentioned above, the settings are loaded once the file is read only and cannot be overwritten by what ever process tries to do so. I probably won't be able to look into it myself (skill issue) but I think that the settings screen might have some extra call (like create config file if it doesn't exist) that is called all the time instead of on some condition (since the process of loading the config continues even after it tries to overwrite the file).

I see that the PR (or the repo it's from) doesn't have a build of the plugin as the artifacts in actions expired. I may try to build and test it tomorrow to report whether it was fixed or not.

So I tried it now in case it would be easy but I'm having troubles compiling it.

git clone https://github.com/MBR-0001/jellyfin-plugin-opensubtitles.git
cd jellyfin-plugin-opensubtitles
git checkout 10-9-support
nix-shell -p dotnet-sdk_8 --run "dotnet publish --configuration Release --output bin"

I get errors about a missing namespace

MSBuild version 17.9.4+90725d08d for .NET
  Determining projects to restore...
  Restored /home/jirka/Projects/jellyfin-plugin-opensubtitles/Jellyfin.Plugin.OpenSubtitles/Jellyfin.Plugin.OpenSubtitles.csproj (in 3.91 sec).
  Restored /home/jirka/Projects/jellyfin-plugin-opensubtitles/tests/Jellyfin.Plugin.OpenSubtitles.Tests/Jellyfin.Plugin.OpenSubtitles.Tests.csproj (in 5.08 sec).
/nix/store/g0l1sx6znj8a3zyapdz56gkyahihhdpf-dotnet-sdk-8.0.201/sdk/8.0.201/Current/SolutionFile/ImportAfter/Microsoft.NET.Sdk.Solution.targets(36,5): warning NETSDK1194: The "--output" option isn't supported when building a solution. Specifying a solution-level output path results in all projects copying outputs to the same directory, which can lead to inconsistent builds. [/home/jirka/Projects/jellyfin-plugin-opensubtitles/Jellyfin.Plugin.OpenSubtitles.sln]
/home/jirka/Projects/jellyfin-plugin-opensubtitles/Jellyfin.Plugin.OpenSubtitles/PluginServiceRegistrator.cs(11,41): error CS0246: The type or namespace name 'IPluginServiceRegistrator' could not be found (are you missing a using directive or an assembly reference?) [/home/jirka/Projects/jellyfin-plugin-opensubtitles/Jellyfin.Plugin.OpenSubtitles/Jellyfin.Plugin.OpenSubtitles.csproj]

You would need to use the unstable nuget feed to build 10.9 plugins

You would need to use the unstable nuget feed to build 10.9 plugins

I'm sorry but I cannot find where to get the prerelease/unstable source that I could add. Is it some Jellyfin repo or some Nuget prerelease/unstable repo?

I got the build working - thanks for your help with the links <3

It looks like the issues with saving credentials aren't present in 3b0fc0a (which was the latest commit I built the plugin with). It looks like only the version in the unstable repo has this issue.

So far everything looks fine so I'll be closing this as this issue will be resolved as soon as #115 is merged and published.