{"record":{"id":"a66c5fa4cd2379ee","repo":"LykosAI/StabilityMatrix","slug":"failed-to-parse-parameters","errorCode":null,"errorMessage":"Failed to parse parameters","messagePattern":"Failed to parse parameters","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs","lineNumber":261,"sourceCode":"                if (this is IImageGalleryComponent imageGalleryComponent)\n                {\n                    Dispatcher.UIThread.Invoke(() =>\n                        imageGalleryComponent.LoadImagesToGallery(new ImageSource(imageFilePath))\n                    );\n                }\n\n                return;\n            }\n        }\n\n        // Has generic metadata\n        if (metadata.Parameters is not null)\n        {\n            Logger.Info(\"Loading Parameters from metadata\");\n\n            if (!GenerationParameters.TryParse(metadata.Parameters, out var parameters))\n            {\n                throw new ApplicationException(\"Failed to parse parameters\");\n            }\n\n            if (this is IParametersLoadableState paramsLoadableVm)\n            {\n                Dispatcher.UIThread.Invoke(() => paramsLoadableVm.LoadStateFromParameters(parameters));\n            }\n            else\n            {\n                Logger.Warn(\n                    \"Load parameters target {Type} does not implement IParametersLoadableState, skipping\",\n                    GetType().Name\n                );\n            }\n\n            // Load image\n            if (this is IImageGalleryComponent imageGalleryComponent)\n            {\n                Dispatcher.UIThread.Invoke(() =>","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs#L243-L279","documentation":"LoadImageMetadata in InferenceTabViewModelBase reads a dropped/opened image's metadata and calls GenerationParameters.TryParse on the 'Parameters' (SMProject-style) JSON payload. When the stored parameters string cannot be deserialized into a GenerationParameters object, it throws this ApplicationException. This is a deliberate hard failure because continuing with partial inference settings would corrupt the restored tab state.","triggerScenarios":"Calling LoadImageMetadata (via Drop or AddTabFromFileAsync) on an image whose metadata 'Parameters' field is present but not valid GenerationParameters JSON — e.g. parameters written by a newer/older Stability Matrix version, hand-edited EXIF/PNG chunks, or metadata copied from another tool.","commonSituations":"Dragging an inference image generated by a different Stability Matrix version whose GenerationParameters schema has changed; images edited in external tools that mangled the embedded parameter JSON; manually copying parameters between images with wrong quoting.","solutions":["Regenerate or re-export the image from Stability Matrix so the Parameters metadata is written by the current version","Inspect the image's embedded metadata and fix the Parameters JSON so it matches the current GenerationParameters schema","Upgrade Stability Matrix if the image came from a newer version that changed the schema","Catch the ApplicationException in the Drop/AddTabFromFileAsync path and fall back to opening the image without parameters"],"exampleFix":"// before\nif (!GenerationParameters.TryParse(metadata.Parameters, out var parameters))\n    throw new ApplicationException(\"Failed to parse parameters\");\n\n// after\nif (!GenerationParameters.TryParse(metadata.Parameters, out var parameters))\n{\n    Logger.Warn(\"Could not parse Parameters metadata; loading image without parameters\");\n    return; // or load defaults instead of throwing\n}","handlingStrategy":"try-catch","validationCode":"// Before calling LoadImageMetadata\nvar meta = ImageMetadata.TryExtract(filePath);\nif (meta?.Parameters is not null &&\n    !GenerationParameters.TryParse(meta.Parameters, out _))\n{\n    Logger.Warn(\"Image has unparseable Parameters metadata; will load without parameters\");\n}","typeGuard":"bool HasParsableParameters(ImageMetadata m) =>\n    m.Parameters is null || GenerationParameters.TryParse(m.Parameters, out _);","tryCatchPattern":"try\n{\n    tabVm.LoadImageMetadata(sender, filePath);\n}\ncatch (ApplicationException ex) when (ex.Message == \"Failed to parse parameters\")\n{\n    Logger.Warn(ex, \"Parameter metadata unreadable; opening image without parameters\");\n    tabVm.OpenImageWithoutParameters(filePath);\n}","preventionTips":["Never hand-edit the embedded Parameters metadata of inference images","Keep Stability Matrix updated so writer/reader schemas match","Avoid running images through external tools that rewrite metadata before importing","Wrap Drop/AddTabFromFileAsync in try-catch with a graceful no-parameters fallback"],"tags":["metadata","json-parse-error","avalonia","inference"],"backgroundTag":"json-parse-error","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}