LykosAI/StabilityMatrix · error · InvalidOperationException
Expected network name.
Error message
Expected network name.
What it means
Thrown by ParseNetwork when the token following the ':' after the network type is missing or not scoped as 'meta.embedded.network.model.prompt'. The parser needs the model file name (without extension) at that position. Message reads 'Expected network name.'
Solutions
- Provide the model name after the colon: '<lora:myModel:0.8>'
- Use the model file name without the .safetensors/.ckpt extension, matching how the tokenizer scopes it
- Ensure no double colons or empty name segments inside the tag
- Catch InvalidOperationException to reject malformed network tags with a clear message
Example fix
// before var prompt = "<lora::0.8>"; // after var prompt = "<lora:myModel:0.8>";
Defensive patterns
Strategy: validation
Validate before calling
bool HasModelName(string tag) => System.Text.RegularExpressions.Regex.IsMatch(tag, "^<[a-zA-Z]+:[^:<> ]+");
Type guard
null
Try / catch
try { var node = builder.Parse(prompt); } catch (InvalidOperationException ex) when (ex.Message.Contains("network name")) { // report empty model name after ':' } Prevention
- Never leave the model name empty or the placeholder unfilled
- Use the model file name without extension as the name segment
- Reject tags with consecutive colons during validation
- Prefill tag names from the model browser UI
When it happens
Trigger: Input like '<lora:>' with an empty name, '<lora::1.0>' with a second colon but no name, or input ending after the first ':'.
Common situations: Templates with '<lora:NAME:0.7>' placeholders left unfilled; users deleting the model name when editing prompts; tags copied from tools where the name part got truncated.
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
- Expected opening bracket.
- Expected network type.
- Expected colon.
- Expected network weight.
- Expected closing bracket.
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/8755a8115f433110.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Core/Models/PromptSyntax/PromptSyntaxBuilder.cs:257
|| !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
var nextToken = PeekToken();
if (nextToken is not null && nextToken.Scopes.Contains("punctuation.separator.variable.prompt"))
{
ConsumeToken(); // consume colon
// Parse the model weight.
var modelWeightToken = ConsumeToken();
if (modelWeightToken is null || !modelWeightToken.Scopes.Contains("constant.numeric"))
throw new InvalidOperationException("Expected network weight.");
modelWeight = ParseNumber();
View on GitHub (pinned to af93d6ef57)