XenorPLxx/playnite-library-psn

Import consistently fails with "Object reference not set to an instance of an object"

Closed this issue ยท 5 comments

Every time I import I get this error.

I backed up my whole library and experimented to see if I could find what might be triggering this: If I completely delete my library files, I can import again, no problem... but I have a bunch of tags on my playstation games so don't really want to start over from scratch. I also tried just deleting all records from playstation sources inside the app, and that doesn't work.

Some entries are getting updated during the import, so I'm imagining there is just one that is somehow not working right, but I don't know which. If you've got a way to identify which entry is the problem I'd be happy experimenting more. Also, if there is a guide to build playnite and this extension to debug the issue, I'd be willing to try that out!

Diagnostics ID
9dce44c3-d861-4c8e-a30d-5eea4ffb1f27

Uh this reminds me I need to update the bug template, I don't actually have access to diagnostics, this is copied over from Playnite maintainers repo. In Playnite data folder (you can access it trough menu->about->data or smt like that) there's and extension.log file, let's start by looking at that - I'll be able to see where it fails and compile a version with some extra debugging info.

Ah, and if you want to try and check it for yourself, you'd need to grab a copy of the plugin, build it in debug, point Playnite to the debug DLL trough settings and then attach Visual Studio onto Playnite - no need to build Playnite itself, just the plugin.

Here's the Playnite setting that's required:
https://api.playnite.link/docs/tutorials/extensions/plugins.html#3-make-playnite-load-new-extension

Debugged this and the problem was

https://github.com/XenorPLxx/playnite-library-psn/blob/main/Services/ImportGames.cs#L171

And line 175 below that. There were "alreadyImportedGames" in my library from past playstation imports that had a null source. There were two like this, and they were both demos, and they were both marked hidden, probably at some point I hid them to remove demos from my visible list.

I could workaround by setting the source myself. To fix in code, I could change in both cases

alreadyImportedGames.Source.ToString() to alreadyImportedGames.Source?.ToString()

but then the source never gets filled in... seems better to check for null OR the value of the source string (so the importer will add a source if there wasn't one already)

Oh, that piece of code is actually a pretty new addition. Thanks for the write-up, I'll try to get around to it over the weekend and add a patch that'll work for your situation and still fill in the source.

Fixed in https://github.com/XenorPLxx/playnite-library-psn/releases/tag/2.32.
Let me know if you spot any more issues.