Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Crash opening app: "An unhandled exception occured: 'N' is an invalid start of a value" #155

Closed
kwaegel opened this issue Dec 11, 2023 · 2 comments · Fixed by #158
Closed

Comments

@kwaegel
Copy link
Contributor

kwaegel commented Dec 11, 2023

Describe the bug
Opening the app causes a pop-up error with the message: "An unhandled exception occured: 'N' is an invalid start of a value. Path: $.safetensors-metadata | LineNumber: 65293 | BytePositionInLine: 28."

This may be a duplicate of issue 116, but that one was marked as being related to images from Easy Diffusion, which I don't use.

Version:
1.4

To Reproduce
Open the app

Expected behavior
App should not crash.

Source Image
I'm assuming one of the recently generated images has invalid metadata that can't be parsed, or got added to the database in an invalid format, but the log does not contain enough information to figure out which one.

I have images generated using Automatic1111, ComfyUI, and InvokeAI.

Source Image or Screenshots
Screenshot and DiffusionToolkit.log attached.

Screenshot 2023-12-10 175741

DiffusionToolkit.log

@kwaegel
Copy link
Contributor Author

kwaegel commented Dec 19, 2023

I ran this under a debugger and tracked down the problem file. Turns out it's the Automatic1111 cache.json file that is failing to parse. Apparently one of the checkpoints contained invalid metadata, which got cached, and thus the cache file can't be parsed.

I heavily trimmed version of the JSON file shows the problem seems to be in parsing a literal NaN value that is not valid JSON. Trimming down the giant file to something readable gives roughly this nesting tree:

{
    "safetensors-metadata": {
        "checkpoint/XYZ.safetensors": {
            "value": {
                "prompt": {
                    "123": {
                        "is_changed": [
                            NaN
                        ]
                    }

This is probbaly a bug on the Automatic1111 side (writing invalid JSON data), but DiffusionToolkit should probably report which file is failing to parse, or maybe even automatically replace NaN with "null" if this is a common problem.

@kwaegel
Copy link
Contributor Author

kwaegel commented Dec 19, 2023

I haven't written C# in a while, but the PR above seems like it should fix the immediate issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant