{"record":{"id":"2a1d29be32e803e5","repo":"LykosAI/StabilityMatrix","slug":"expected-closing-bracket","errorCode":null,"errorMessage":"Expected closing bracket.","messagePattern":"Expected closing bracket\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Models/PromptSyntax/PromptSyntaxBuilder.cs","lineNumber":295,"sourceCode":"            nextToken = PeekToken();\n            if (nextToken is not null && nextToken.Scopes.Contains(\"punctuation.separator.variable.prompt\"))\n            {\n                ConsumeToken(); // consume colon\n\n                // Parse the clip weight.\n                var clipWeightToken = ConsumeToken();\n                if (clipWeightToken is null || !clipWeightToken.Scopes.Contains(\"constant.numeric\"))\n                    throw new InvalidOperationException(\"Expected network weight.\");\n                clipWeight = ParseNumber();\n            }\n        }\n\n        var endNetworkToken = ConsumeToken();\n        if (\n            endNetworkToken is null\n            || !endNetworkToken.Scopes.Contains(\"punctuation.definition.network.end.prompt\")\n        )\n            throw new InvalidOperationException(\"Expected closing bracket.\");\n\n        return new NetworkNode\n        {\n            Span = TextSpan.FromBounds(beginNetworkToken.StartIndex, endNetworkToken.EndIndex),\n            NetworkType = type,\n            ModelName = name,\n            ModelWeight = modelWeight,\n            ClipWeight = clipWeight,\n        };\n    }\n\n    private ArrayNode ParseArray()\n    {\n        var openBracket = ConsumeToken();\n        if (openBracket is null || !openBracket.Scopes.Contains(\"punctuation.definition.array.begin.prompt\"))\n            throw new InvalidOperationException(\"Expected opening bracket.\");\n\n        var node = new ArrayNode","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Models/PromptSyntax/PromptSyntaxBuilder.cs#L277-L313","documentation":"Thrown by ParseNetwork at the end of parsing a network directive: the consumed token must close the tag with a '>' scoped as 'punctuation.definition.network.end.prompt'. If it is missing or scoped differently, the parser throws 'Expected closing bracket.' Unlike the weighted-group parser, it checks only the scope, not the literal text.","triggerScenarios":"Input like '<lora:name:0.8' with the closing '>' missing, or the '>' tokenized with unexpected scopes (e.g. treated as HTML by the tokenizer grammar), or input truncated before the '>'.","commonSituations":"LoRA tags truncated by copy/paste or prompt-length limits; text written in editors that escape or split '>'; grammar version mismatches between the tokenizer and PromptSyntaxBuilder scope expectations.","solutions":["Close every network tag with '>': '<lora:name:0.8>'","Check the tokenizer grammar scopes the closing '>' as punctuation.definition.network.end.prompt","If truncation by prompt-length limits is the cause, trim earlier parts of the prompt instead of the tag","Catch InvalidOperationException and report the unterminated tag position to the user"],"exampleFix":"// before\nvar prompt = \"<lora:myModel:0.8\";\n// after\nvar prompt = \"<lora:myModel:0.8>\";","handlingStrategy":"validation","validationCode":"bool HasClosingBracket(string tag) { int depth = 0; foreach (var c in tag) { if (c=='<') depth++; else if (c=='>') depth--; if (depth < 0) return false; } return depth == 0; }","typeGuard":"null","tryCatchPattern":"try { var node = builder.Parse(prompt); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"closing bracket\")) { // report unterminated network tag with its start index }","preventionTips":["Close every '<...>' network tag with '>'","Watch for prompt-length truncation cutting off trailing '>'","Sanitize text pasted from HTML-aware editors that may mangle '>'","Keep the textmate grammar aligned with the parser's scope expectations"],"tags":["parser","prompt-syntax","lora","closing-bracket","tokenizer"],"backgroundTag":"invalid-argument-format","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"}