LykosAI/StabilityMatrix · error · InvalidOperationException

Expected opening bracket.

Error message

Expected opening bracket.

What it means

Thrown by ParseNetwork at the start of parsing a network (LoRA/LyCORIS) directive, which must begin with a '<' token scoped as 'punctuation.definition.network.begin.prompt'. If the consumed token is missing or lacks that scope, the parser assumes the '<xyz:...>' syntax was attempted but malformed.

Solutions

  1. Write the full network tag: '<lora:name:0.8>' with opening '<' and closing '>'
  2. Remove stray '<' characters that are not network tags from the prompt
  3. Verify the tokenizer grammar recognizes the '<' as punctuation.definition.network.begin.prompt
  4. Catch InvalidOperationException and show the user which part of the prompt is malformed

Example fix

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

Strategy: validation

Validate before calling

static readonly System.Text.RegularExpressions.Regex NetworkTag = new("<lora:[^:<>]+(:[0-9.]+)?(:[0-9.]+)?>"); bool HasWellFormedNetworkTag(string prompt) => NetworkTag.IsMatch(prompt);

Type guard

null

Try / catch

try { var node = builder.Parse(prompt); } catch (InvalidOperationException ex) when (ex.Message.Contains("opening bracket")) { // flag stray '<' characters in the prompt }

Prevention

When it happens

Trigger: Parsing a prompt containing '<' that is not a valid network opener, e.g. '<lora' cut off, or a stray '<' used as a comparison/text character that the tokenizer did not scope as a network begin.

Common situations: A1111/ComfyUI users paste LoRA tags like '<lora:model:1>' from other tools into a prompt that Stability Matrix tokenizes differently; truncated '<lora' tags when copying prompts; XML-like fragments in prompt text.

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/42e304883fa41109. Report an issue: GitHub.

Appendix: source

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

            }
            else
            {
                // It's part of the content.
                node.Content.Add(ParseNode()); // Recursively parse nested nodes.
            }
        }

        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();

View on GitHub (pinned to af93d6ef57)