LykosAI/StabilityMatrix · error · ValidationException

Fields line not found

Error message

Fields line not found

What it means

GenerationParameters.Parse parses plaintext generation-parameter blocks (e.g. from PNG metadata). It splits the text into lines and expects the last line to be the 'Fields:'-style parameter line starting with 'Steps:'; when the text has no usable last line it throws ValidationException('Fields line not found'). This guards against empty or unparseable prompt payloads.

Solutions

  1. Verify the text contains a trailing line starting with 'Steps:' before parsing
  2. Use TryParse instead of Parse so parse failures return false instead of throwing
  3. Normalize line endings (replace '\r\n' with '\n') before parsing
  4. Extract parameters only from images known to carry A1111-style metadata

Example fix

// before
var parameters = GenerationParameters.Parse(metadataText);
// after
if (!GenerationParameters.TryParse(metadataText, out var parameters))
{
    Logger.Debug("No generation parameters in metadata");
    return GenerationParameters.Default;
}
Defensive patterns

Strategy: type-guard

Validate before calling

static bool LooksLikeGenerationParameters(string text) =>
    !string.IsNullOrWhiteSpace(text) &&
    text.Split(new[]{'\n','\r'}).LastOrDefault(l => !string.IsNullOrWhiteSpace(l))?.StartsWith("Steps:") == true;

Type guard

bool TryGetParameters(string? text, out GenerationParameters parameters) =>
    GenerationParameters.TryParse(text, out parameters) ;

Try / catch

try { parameters = GenerationParameters.Parse(text); }
catch (ValidationException) { parameters = null; /* no parameter footer in metadata */ }

Prevention

When it happens

Trigger: Calling GenerationParameters.Parse (or TryParse) with an empty string, a prompt without a trailing parameter line, or metadata text where parameters were stripped; also when only '\r\n' line endings exist and the last-line check on the first split fails before the CRLF retry.

Common situations: Importing images generated by other tools that omit the A1111-style footer; user-edited prompt text with the parameters line deleted; exotic line endings defeating the split.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12). Data as JSON: /api/errors/d3934372c971ede2. Report an issue: GitHub.

Appendix: source

Thrown at StabilityMatrix.Core/Models/GenerationParameters.cs:69

        {
            generationParameters = Parse(text);
        }
        catch (Exception)
        {
            generationParameters = null;
            return false;
        }

        return true;
    }

    public static GenerationParameters Parse(string text)
    {
        var lines = text.Split('\n');

        if (lines.LastOrDefault() is not { } lastLine)
        {
            throw new ValidationException("Fields line not found");
        }

        if (lastLine.StartsWith("Steps:") != true)
        {
            lines = text.Split("\r\n");
            lastLine = lines.LastOrDefault() ?? string.Empty;

            if (lastLine.StartsWith("Steps:") != true)
            {
                throw new ValidationException("Unable to locate starting marker of last line");
            }
        }

        // Join lines before last line, split at 'Negative prompt: '
        var joinedLines = string.Join("\n", lines[..^1]).Trim();

        // Apparently there is no space after the colon if value is empty, so check and add space here
        if (joinedLines.EndsWith("Negative prompt:"))

View on GitHub (pinned to af93d6ef57)