mregni / EmbyStat

Multiplatform statistics server for Emby server
MIT License
286 stars 21 forks source link

ArgumentNullException on media sync #1338

Closed cavemandaveman closed 4 years ago

cavemandaveman commented 4 years ago

Bug report

Describe the bug Media sync fails with ArgumentNullException

To Reproduce Initiate a media sync, look at logs

Expected behavior Successful media sync

System (please complete the following information):

Additional context I can see in the logs it attempts to sync the Movie library, starts by syncing movie Collections, then errors out:

2020-08-21 17:53:07.5530 [ERROR] Error while running job System.ArgumentNullException: Value cannot be null. (Parameter 'entity')
   at LiteDB.BsonMapper.ToDocument(Type type, Object entity)
   at LiteDB.BsonMapper.ToDocument[T](T entity)
   at LiteDB.LiteCollection`1.GetBsonDocs(IEnumerable`1 documents)+MoveNext()
   at LiteDB.Engine.LiteEngine.<>c__DisplayClass30_0.<Upsert>b__0(TransactionService transaction)
   at LiteDB.Engine.LiteEngine.AutoTransaction[T](Func`2 fn)
   at LiteDB.Engine.LiteEngine.Upsert(String collection, IEnumerable`1 docs, BsonAutoId autoId)
   at LiteDB.SharedEngine.Upsert(String collection, IEnumerable`1 docs, BsonAutoId autoId)
   at LiteDB.LiteCollection`1.Upsert(IEnumerable`1 entities)
   at EmbyStat.Repositories.MovieRepository.<>c__DisplayClass1_0.<UpsertRange>b__0()
   at EmbyStat.Repositories.BaseRepository.ExecuteQuery(Action query)
   at EmbyStat.Repositories.MovieRepository.UpsertRange(IEnumerable`1 movies)
   at EmbyStat.Jobs.Jobs.Sync.MediaSyncJob.ProcessMoviesAsync(IReadOnlyList`1 libraries, CancellationToken cancellationToken)
   at EmbyStat.Jobs.Jobs.Sync.MediaSyncJob.RunJobAsync()
   at EmbyStat.Jobs.BaseJob.Execute()
2020-08-21 17:53:07.5709 [WARN] MEDIA-SYNC      Job failed, check logs for more info. 
2020-08-21 17:53:07.7705 [ERROR] Failed to process the job '04cdad8e-0290-4d12-98e8-8928b62d6856': an exception occurred. System.ArgumentNullException: Value cannot be null. (Parameter 'entity')
   at LiteDB.BsonMapper.ToDocument(Type type, Object entity)
   at LiteDB.BsonMapper.ToDocument[T](T entity)
   at LiteDB.LiteCollection`1.GetBsonDocs(IEnumerable`1 documents)+MoveNext()
   at LiteDB.Engine.LiteEngine.<>c__DisplayClass30_0.<Upsert>b__0(TransactionService transaction)
   at LiteDB.Engine.LiteEngine.AutoTransaction[T](Func`2 fn)
   at LiteDB.Engine.LiteEngine.Upsert(String collection, IEnumerable`1 docs, BsonAutoId autoId)
   at LiteDB.SharedEngine.Upsert(String collection, IEnumerable`1 docs, BsonAutoId autoId)
   at LiteDB.LiteCollection`1.Upsert(IEnumerable`1 entities)
   at EmbyStat.Repositories.MovieRepository.<>c__DisplayClass1_0.<UpsertRange>b__0()
   at EmbyStat.Repositories.BaseRepository.ExecuteQuery(Action query)
   at EmbyStat.Repositories.MovieRepository.UpsertRange(IEnumerable`1 movies)
   at EmbyStat.Jobs.Jobs.Sync.MediaSyncJob.ProcessMoviesAsync(IReadOnlyList`1 libraries, CancellationToken cancellationToken)
   at EmbyStat.Jobs.Jobs.Sync.MediaSyncJob.RunJobAsync()
   at EmbyStat.Jobs.BaseJob.Execute()
   at EmbyStat.Jobs.BaseJob.Execute()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
mregni commented 4 years ago

@cavemandaveman, can you send me a log while running EmbyStat with the --log-level=1 flag? This way it will add a lot more debug information to find the missing property.

cavemandaveman commented 4 years ago

Here is the full entry with debug:

2020-08-21 17:53:05.7368 [INFO] MEDIA-SYNC      Starting job 
2020-08-21 17:53:05.7513 [DEBUG] BASE-HTTP-CLIENT       External call: [POST]http://xx.xx.xx.xx:8096//System/Ping 
2020-08-21 17:53:05.7569 [DEBUG] BASE-HTTP-CLIENT       Ping returned: Jellyfin Server 
2020-08-21 17:53:05.7569 [INFO] MEDIA-SYNC      First delete all existing media and root media libraries from database so we have a clean start. 
2020-08-21 17:53:05.7569 [INFO] MEDIA-SYNC      Asking MediaServer for all root folders 
2020-08-21 17:53:05.7569 [DEBUG] BASE-HTTP-CLIENT       External call: [GET]http://xx.xx.xx.xx:8096/Library/MediaFolders 
2020-08-21 17:53:05.7783 [INFO] MEDIA-SYNC      Found 6 root items, getting ready for processing 
2020-08-21 17:53:05.7783 [INFO] MEDIA-SYNC      Lets start processing movies 
2020-08-21 17:53:05.7939 [DEBUG] BASE-HTTP-CLIENT       External call: [GET]http://xx.xx.xx.xx:8096/Items 
2020-08-21 17:53:05.8406 [INFO] MEDIA-SYNC      Found 130 movies in Movies library 
2020-08-21 17:53:05.8406 [DEBUG] BASE-HTTP-CLIENT       External call: [GET]http://xx.xx.xx.xx:8096/Items 
2020-08-21 17:53:072020-08-21 17:53:07.5363 [WARN] BASE-HTTP-CLIENT        Value cannot be null. (Parameter 'source') 
2020-08-21 17:53:07.5363 [DEBUG] BASE-HTTP-CLIENT       DTO object tried to convert 
2020-08-21 17:53:07.5363 [DEBUG] BASE-HTTP-CLIENT       {"Id":"89f050d95c606a200bba24928940a9fa","DateCreated":"2020-07-25T18:52:41+00:00","ImageTags":{"Primary":"b98b3384b37c21f05c457dba9abf635a","Logo":"5bbc1e5bf49a8e281f9c3723cde70d18","Thumb":"2b0d481507717cb2a6837c9c6ee668b9"},"BackdropImageTags":null,"Name":"Star Wars","ParentId":"8679d10569ec12981200c4116da3e90b","Path":"/var/lib/jellyfin/data/collections/Star Wars
 [boxset]","PremiereDate":"1977-05-25T00:00:00+00:00","ProductionYear":1977,"SortName":"star wars","Status":null,"OriginalTitle":null,"Container":null,"MediaType":null,"MediaSources":null,"MediaStreams":null,"Video3DFormat":null,"CommunityRating":null,"ProviderIds":{"Tmdb":"10"},"RunTimeTicks":null,"OfficialRating":"PG","People":[],"Genres":["Adventure","Action","Science Fiction","Fantasy"],"IndexNumber":null,"IndexNumberEnd":null,"Type":"BoxSet","SeriesName":null,"CollectionType":null,"Etag":null,"Overview":"An epic space-opera theatrical film series, which depicts the adventures of various characters \"a long time ago in a galaxy far, far away�<80>�.\""} 
2020-08-21 17:53:07.5530 [ERROR] Error while running job System.ArgumentNullException: Value cannot be null. (Parameter 'entity')
   at LiteDB.BsonMapper.ToDocument(Type type, Object entity)
   at LiteDB.BsonMapper.ToDocument[T](T entity)
   at LiteDB.LiteCollection`1.GetBsonDocs(IEnumerable`1 documents)+MoveNext()
   at LiteDB.Engine.LiteEngine.<>c__DisplayClass30_0.<Upsert>b__0(TransactionService transaction)
   at LiteDB.Engine.LiteEngine.AutoTransaction[T](Func`2 fn)
   at LiteDB.Engine.LiteEngine.Upsert(String collection, IEnumerable`1 docs, BsonAutoId autoId)
   at LiteDB.SharedEngine.Upsert(String collection, IEnumerable`1 docs, BsonAutoId autoId)
   at LiteDB.LiteCollection`1.Upsert(IEnumerable`1 entities)
   at EmbyStat.Repositories.MovieRepository.<>c__DisplayClass1_0.<UpsertRange>b__0()
   at EmbyStat.Repositories.BaseRepository.ExecuteQuery(Action query)
   at EmbyStat.Repositories.MovieRepository.UpsertRange(IEnumerable`1 movies)
   at EmbyStat.Jobs.Jobs.Sync.MediaSyncJob.ProcessMoviesAsync(IReadOnlyList`1 libraries, CancellationToken cancellationToken)
   at EmbyStat.Jobs.Jobs.Sync.MediaSyncJob.RunJobAsync()
   at EmbyStat.Jobs.BaseJob.Execute()
2020-08-21 17:53:07.5709 [WARN] MEDIA-SYNC      Job failed, check logs for more info. 
2020-08-21 17:53:07.7705 [ERROR] Failed to process the job '04cdad8e-0290-4d12-98e8-8928b62d6856': an exception occurred. System.ArgumentNullException: Value cannot be null. (Parameter 'entity')
   at LiteDB.BsonMapper.ToDocument(Type type, Object entity)
   at LiteDB.BsonMapper.ToDocument[T](T entity)
   at LiteDB.LiteCollection`1.GetBsonDocs(IEnumerable`1 documents)+MoveNext()
   at LiteDB.Engine.LiteEngine.<>c__DisplayClass30_0.<Upsert>b__0(TransactionService transaction)
   at LiteDB.Engine.LiteEngine.AutoTransaction[T](Func`2 fn)
   at LiteDB.Engine.LiteEngine.Upsert(String collection, IEnumerable`1 docs, BsonAutoId autoId)
   at LiteDB.SharedEngine.Upsert(String collection, IEnumerable`1 docs, BsonAutoId autoId)
   at LiteDB.LiteCollection`1.Upsert(IEnumerable`1 entities)
   at EmbyStat.Repositories.MovieRepository.<>c__DisplayClass1_0.<UpsertRange>b__0()
   at EmbyStat.Repositories.BaseRepository.ExecuteQuery(Action query)
   at EmbyStat.Repositories.MovieRepository.UpsertRange(IEnumerable`1 movies)
   at EmbyStat.Jobs.Jobs.Sync.MediaSyncJob.ProcessMoviesAsync(IReadOnlyList`1 libraries, CancellationToken cancellationToken)
   at EmbyStat.Jobs.Jobs.Sync.MediaSyncJob.RunJobAsync()
   at EmbyStat.Jobs.BaseJob.Execute()
   at EmbyStat.Jobs.BaseJob.Execute()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
mregni commented 4 years ago

This issue is fixed in beta.24. Feel free to reopen if the issue still persists.

cavemandaveman commented 4 years ago

With beta.24, the ArgumentNullException turned into a NullReferenceException, similar to the previous issue #1155

2020-09-09 21:48:30.8002 [INFO] MEDIA-SYNC  Starting job 
2020-09-09 21:48:30.8217 [DEBUG] BASE-HTTP-CLIENT   External call: [POST]http://xx.xx.xx.xx:8096//System/Ping 
2020-09-09 21:48:30.8425 [DEBUG] BASE-HTTP-CLIENT   Ping returned: Jellyfin Server 
2020-09-09 21:48:30.8425 [INFO] MEDIA-SYNC  First delete all existing media and root media libraries from database so we have a clean start. 
2020-09-09 21:48:30.8425 [INFO] MEDIA-SYNC  Asking MediaServer for all root folders 
2020-09-09 21:48:30.8464 [DEBUG] BASE-HTTP-CLIENT   External call: [GET]http://xx.xx.xx.xx:8096/Library/MediaFolders 
2020-09-09 21:48:30.8764 [INFO] MEDIA-SYNC  Found 6 root items, getting ready for processing 
2020-09-09 21:48:30.8778 [INFO] MEDIA-SYNC  Lets start processing movies 
2020-09-09 21:48:30.9113 [DEBUG] BASE-HTTP-CLIENT   External call: [GET]http://xx.xx.xx.xx:8096/Items 
2020-09-09 21:48:30.9809 [INFO] MEDIA-SYNC  Found 144 movies in Movies library 
2020-09-09 21:48:30.9838 [DEBUG] BASE-HTTP-CLIENT   External call: [GET]http://xx.xx.xx.xx:8096/Items 
2020-09-09 21:48:32.7709 [WARN] BASE-HTTP-CLIENT    Value cannot be null. (Parameter 'source') 
2020-09-09 21:48:32.7709 [DEBUG] BASE-HTTP-CLIENT   Tried to convert Movie 
2020-09-09 21:48:32.7709 [DEBUG] BASE-HTTP-CLIENT   {"Id":"89f050d95c606a200bba24928940a9fa","DateCreated":"2020-07-25T18:52:41+00:00","ImageTags":{"Primary":"b98b3384b37c21f05c457dba9abf635a","Logo":"5bbc1e5bf49a8e281f9c3723cde70d18","Thumb":"2b0d481507717cb2a6837c9c6ee668b9"},"BackdropImageTags":null,"Name":"Star Wars","ParentId":"8679d10569ec12981200c4116da3e90b","Path":"/var/lib/jellyfin/data/collections/Star Wars [boxset]","PremiereDate":"1977-05-25T00:00:00+00:00","ProductionYear":1977,"SortName":"star wars","Status":null,"OriginalTitle":null,"Container":null,"MediaType":null,"MediaSources":null,"MediaStreams":null,"Video3DFormat":null,"CommunityRating":null,"ProviderIds":{"Tmdb":"10"},"RunTimeTicks":null,"OfficialRating":"PG","People":[],"Genres":["Adventure","Action","Science Fiction","Fantasy"],"IndexNumber":null,"IndexNumberEnd":null,"Type":"BoxSet","SeriesName":null,"CollectionType":null,"Etag":null,"Overview":"An epic space-opera theatrical film series, which depicts the adventures of various characters \"a long time ago in a galaxy far, far away….\""} 
2020-09-09 21:48:32.8918 [ERROR] Error while running job System.NullReferenceException: Object reference not set to an instance of an object.
   at EmbyStat.Jobs.Jobs.Sync.MediaSyncJob.<>c.<ProcessMoviesAsync>b__17_2(Movie x)
   at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
   at LiteDB.LiteCollection`1.GetBsonDocs(IEnumerable`1 documents)+MoveNext()
   at LiteDB.Engine.LiteEngine.<>c__DisplayClass30_0.<Upsert>b__0(TransactionService transaction)
   at LiteDB.Engine.LiteEngine.AutoTransaction[T](Func`2 fn)
   at LiteDB.Engine.LiteEngine.Upsert(String collection, IEnumerable`1 docs, BsonAutoId autoId)
   at LiteDB.SharedEngine.Upsert(String collection, IEnumerable`1 docs, BsonAutoId autoId)
   at LiteDB.LiteCollection`1.Upsert(IEnumerable`1 entities)
   at EmbyStat.Repositories.MovieRepository.<>c__DisplayClass1_0.<UpsertRange>b__0()
   at EmbyStat.Repositories.BaseRepository.ExecuteQuery(Action query)
   at EmbyStat.Repositories.MovieRepository.UpsertRange(IEnumerable`1 movies)
   at EmbyStat.Jobs.Jobs.Sync.MediaSyncJob.ProcessMoviesAsync(IReadOnlyList`1 libraries, CancellationToken cancellationToken)
   at EmbyStat.Jobs.Jobs.Sync.MediaSyncJob.RunJobAsync()
   at EmbyStat.Jobs.BaseJob.Execute()
2020-09-09 21:48:32.9288 [WARN] MEDIA-SYNC  Job failed, check logs for more info. 
2020-09-09 21:48:33.2904 [WARN] Failed to process the job '7292a835-77df-4557-9441-723889d0f498': an exception occurred. Retry attempt 1 of 2 will be performed in 00:00:25. System.NullReferenceException: Object reference not set to an instance of an object.
   at EmbyStat.Jobs.Jobs.Sync.MediaSyncJob.<>c.<ProcessMoviesAsync>b__17_2(Movie x)
   at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
   at LiteDB.LiteCollection`1.GetBsonDocs(IEnumerable`1 documents)+MoveNext()
   at LiteDB.Engine.LiteEngine.<>c__DisplayClass30_0.<Upsert>b__0(TransactionService transaction)
   at LiteDB.Engine.LiteEngine.AutoTransaction[T](Func`2 fn)
   at LiteDB.Engine.LiteEngine.Upsert(String collection, IEnumerable`1 docs, BsonAutoId autoId)
   at LiteDB.SharedEngine.Upsert(String collection, IEnumerable`1 docs, BsonAutoId autoId)
   at LiteDB.LiteCollection`1.Upsert(IEnumerable`1 entities)
   at EmbyStat.Repositories.MovieRepository.<>c__DisplayClass1_0.<UpsertRange>b__0()
   at EmbyStat.Repositories.BaseRepository.ExecuteQuery(Action query)
   at EmbyStat.Repositories.MovieRepository.UpsertRange(IEnumerable`1 movies)
   at EmbyStat.Jobs.Jobs.Sync.MediaSyncJob.ProcessMoviesAsync(IReadOnlyList`1 libraries, CancellationToken cancellationToken)
   at EmbyStat.Jobs.Jobs.Sync.MediaSyncJob.RunJobAsync()
   at EmbyStat.Jobs.BaseJob.Execute()
   at EmbyStat.Jobs.BaseJob.Execute()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

I am not able to reopen this issue