{"record":{"id":"faf445b2df799e57","repo":"LykosAI/StabilityMatrix","slug":"unable-to-locate-starting-marker-of-last-line","errorCode":null,"errorMessage":"Unable to locate starting marker of last line","messagePattern":"Unable to locate starting marker of last line","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"warning","filePath":"StabilityMatrix.Core/Models/GenerationParameters.cs","lineNumber":79,"sourceCode":"    }\n\n    public static GenerationParameters Parse(string text)\n    {\n        var lines = text.Split('\\n');\n\n        if (lines.LastOrDefault() is not { } lastLine)\n        {\n            throw new ValidationException(\"Fields line not found\");\n        }\n\n        if (lastLine.StartsWith(\"Steps:\") != true)\n        {\n            lines = text.Split(\"\\r\\n\");\n            lastLine = lines.LastOrDefault() ?? string.Empty;\n\n            if (lastLine.StartsWith(\"Steps:\") != true)\n            {\n                throw new ValidationException(\"Unable to locate starting marker of last line\");\n            }\n        }\n\n        // Join lines before last line, split at 'Negative prompt: '\n        var joinedLines = string.Join(\"\\n\", lines[..^1]).Trim();\n\n        // Apparently there is no space after the colon if value is empty, so check and add space here\n        if (joinedLines.EndsWith(\"Negative prompt:\"))\n        {\n            joinedLines += ' ';\n        }\n\n        var splitFirstPart = joinedLines.Split(\"Negative prompt: \", 2);\n\n        var positivePrompt = splitFirstPart.ElementAtOrDefault(0)?.Trim();\n        var negativePrompt = splitFirstPart.ElementAtOrDefault(1)?.Trim();\n\n        // Parse last line","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Models/GenerationParameters.cs#L61-L97","documentation":"GenerationParameters.TryParse/Parse parses PNG-embedded generation-parameter text from A1111-style images. The parser expects the last non-empty line to begin with 'Steps:'; if it does not, the format is not recognized and a ValidationException is thrown naming the missing marker.","triggerScenarios":"Calling Parse (via TryParse) with text whose final line does not start with 'Steps:' — e.g. truncated prompt text, images saved by tools that reorder/omit the Steps line, or manually edited parameter blocks.","commonSituations":"Importing images generated by WebUI forks or other tools that write parameters in a different order; a paste/copy of parameter text missing the trailing Steps line; corrupted or trimmed metadata.","solutions":["Ensure the last line of the parameter text starts with 'Steps:' before parsing","Check the image metadata source — re-export or regenerate the image with a tool that embeds standard A1111 parameter blocks","Wrap TryParse in a try-catch and treat ValidationException as 'parameters not parseable' rather than a crash"],"exampleFix":"// before\nvar pars = GenerationParameters.Parse(text);\n// after\nif (GenerationParameters.TryParse(text, out var pars)) { /* use pars */ } else { /* fall back to defaults */ }","handlingStrategy":"validation","validationCode":"var ok = text.Split(\"\\r\\n\").LastOrDefault(l => !string.IsNullOrWhiteSpace(l))?.StartsWith(\"Steps:\") == true;\nif (!ok) /* handle unparsable parameters */;","typeGuard":null,"tryCatchPattern":"try { pars = GenerationParameters.Parse(text); } catch (ValidationException ex) { log.Warn(ex, \"params unparsable\"); pars = null; }","preventionTips":["Prefer TryParse over Parse when parameter text may be malformed","Validate last line starts with 'Steps:' before parsing","Sanity-check image metadata sources before import"],"tags":["csharp","parsing","metadata","validation"],"backgroundTag":"schema-validation-failed","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"}