LykosAI/StabilityMatrix · error · InvalidOperationException

Expected network type.

Error message

Expected network type.

What it means

Thrown by ParseNetwork after the opening '<' when the next token is missing or not scoped as 'meta.embedded.network.type.prompt'. The parser expects a network type identifier (lora, lycoris, etc.) immediately after the opening bracket. The message literally reads 'Expected network type.'

Solutions

  1. Insert a valid network type after '<', e.g. '<lora:name:0.8>'
  2. Use a type the grammar scopes as meta.embedded.network.type.prompt (typically lowercase lora/lycoris)
  3. Check that no character (space-free) separates '<' from the type in a way the tokenizer rejects
  4. Catch InvalidOperationException to report malformed network tags

Example fix

// before
var prompt = "<:myModel:0.8>";
// after
var prompt = "<lora:myModel:0.8>";
Defensive patterns

Strategy: validation

Validate before calling

bool HasNetworkType(string tag) { var m = System.Text.RegularExpressions.Regex.Match(tag, "^<([a-zA-Z]+):"); return m.Success && !string.IsNullOrEmpty(m.Groups[1].Value); }

Type guard

null

Try / catch

try { var node = builder.Parse(prompt); } catch (InvalidOperationException ex) when (ex.Message.Contains("network type")) { // report '<' followed by missing type }

Prevention

When it happens

Trigger: Input like '<:1.0>' or '<' immediately followed by ':' or end of input — no type token between '<' and ':'.

Common situations: Prompts where the type word was deleted during editing; templates with placeholder '<:name:1>' left unfilled; copy/paste truncation cutting '<lora' down to '<'.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at StabilityMatrix.Core/Models/PromptSyntax/PromptSyntaxBuilder.cs:246

            }
        }

        return node;
    }

    private NetworkNode ParseNetwork()
    {
        var beginNetworkToken = ConsumeToken();
        if (
            beginNetworkToken is null
            || !beginNetworkToken.Scopes.Contains("punctuation.definition.network.begin.prompt")
        )
            throw new InvalidOperationException("Expected opening bracket.");

        // type
        var typeToken = PeekToken();
        if (typeToken is null || !typeToken.Scopes.Contains("meta.embedded.network.type.prompt"))
            throw new InvalidOperationException("Expected network type.");
        var type = ParseIdentifier();

        // colon
        var colonToken = ConsumeToken();
        if (colonToken is null || !colonToken.Scopes.Contains("punctuation.separator.variable.prompt"))
            throw new InvalidOperationException("Expected colon.");

        // name
        var nameToken = PeekToken();
        if (nameToken is null || !nameToken.Scopes.Contains("meta.embedded.network.model.prompt"))
            throw new InvalidOperationException("Expected network name.");
        var name = ParseText();

        // model weight, clip weight
        NumberNode? modelWeight = null;
        NumberNode? clipWeight = null;

        // colon

View on GitHub (pinned to af93d6ef57)