{"record":{"id":"9b4069e74b5807fc","repo":"LykosAI/StabilityMatrix","slug":"unexpected-end-of-input","errorCode":null,"errorMessage":"Unexpected end of input.","messagePattern":"Unexpected end of input\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Models/PromptSyntax/PromptSyntaxBuilder.cs","lineNumber":189,"sourceCode":"    {\n        var openParenToken = ConsumeToken(); // Consume the '('\n        if (\n            openParenToken is null\n            || !openParenToken.Scopes.Contains(\"punctuation.definition.array.begin.prompt\")\n        )\n            throw new InvalidOperationException(\"Expected opening parenthesis.\");\n\n        // Set start index\n        var node = new ParenthesizedNode { Span = new TextSpan(openParenToken.StartIndex, 0) };\n\n        while (MoreTokens())\n        {\n            // Check if no more tokens to consume.\n            if (PeekToken() is not { } nextToken)\n            {\n                // Ensure we have length set\n                if (node.Span.Length == 0)\n                    throw new InvalidOperationException(\"Unexpected end of input.\");\n                break;\n            }\n\n            if (nextToken.Scopes.Contains(\"punctuation.separator.weight.prompt\"))\n            {\n                // Parse the weight.\n                ConsumeToken(); // Consume the ':'\n\n                // Check the weight value token.\n                var weightToken = PeekToken();\n                if (weightToken is null || !weightToken.Scopes.Contains(\"constant.numeric\"))\n                {\n                    throw new InvalidOperationException(\"Expected numeric weight value.\");\n                }\n\n                // Consume the weight token.\n                node.Weight = ParseNumber();\n            }","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Models/PromptSyntax/PromptSyntaxBuilder.cs#L171-L207","documentation":"Thrown by ParseParenthesized in PromptSyntaxBuilder when the token stream ends before a parenthesized/weighted prompt group can be parsed and the node has no span length. The parser is driven by textmate scopes, so it only throws this when PeekToken() returns null (no more tokens) while parsing the inside of a '(' group. It is an internal InvalidOperationException, not a checked exception type.","triggerScenarios":"Calling ParseNode/Parse on a prompt string whose text ends right after an opening '(' or a '<' weight separator with nothing (or no further tokens) following, e.g. input like \"(masterpiece:\" or a trailing '(' with no closing tokens.","commonSituations":"Users paste truncated prompts into A1111-compatible prompt fields; prompt-generation code builds strings programmatically and drops the closing parenthesis; weights written as '(word:' without the trailing number and ')'.","solutions":["Close all open parentheses in the prompt text so the token stream contains the closing ')' after the weight","Ensure weighted syntax is complete: '(text:1.2)' rather than '(text:'","If building prompts programmatically, validate balanced parentheses before calling the parser","Catch InvalidOperationException from Parse and surface a 'malformed prompt syntax' message to the user"],"exampleFix":"// before\nvar prompt = \"(detailed face:\";\nvar node = builder.Parse(prompt);\n// after\nvar prompt = \"(detailed face:1.2)\";\nvar node = builder.Parse(prompt);","handlingStrategy":"validation","validationCode":"bool HasBalancedParens(string prompt) { int depth = 0; foreach (var c in prompt) { 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) { // surface ex.Message as malformed prompt syntax to the user }","preventionTips":["Validate balanced parentheses on prompt input before parsing","Never emit a weight separator ':' without a following number and closer","Show live syntax validation in prompt editor UIs","Unit-test prompt strings from import/paste flows"],"tags":["parser","prompt-syntax","unbalanced-parenthesis","stability-matrix"],"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"}