{"record":{"id":"9c670853c483b923","repo":"LykosAI/StabilityMatrix","slug":"expected-opening-brace","errorCode":null,"errorMessage":"Expected opening brace.","messagePattern":"Expected opening brace\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Models/PromptSyntax/PromptSyntaxBuilder.cs","lineNumber":346,"sourceCode":"                break;\n            }\n            else\n            {\n                node.Elements.Add(ParseNode()); // Recursively parse nested nodes.\n            }\n        }\n\n        return node;\n    }\n\n    private WildcardNode ParseWildcard()\n    {\n        var openBraceToken = ConsumeToken(); // Consume the '{'\n        if (\n            openBraceToken is null\n            || !openBraceToken.Scopes.Contains(\"punctuation.definition.wildcard.begin.prompt\")\n        )\n            throw new InvalidOperationException(\"Expected opening brace.\");\n\n        var node = new WildcardNode\n        {\n            Span = new TextSpan(openBraceToken.StartIndex, 0), // Set start index\n        };\n\n        while (MoreTokens())\n        {\n            var nextToken = PeekToken();\n            if (nextToken is null)\n                break;\n\n            if (nextToken.Scopes.Contains(\"punctuation.definition.wildcard.end.prompt\"))\n            {\n                ConsumeToken(); // Consume the '}'\n                node.EndIndex = nextToken.EndIndex;\n                break;\n            }","sourceCodeStart":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Models/PromptSyntax/PromptSyntaxBuilder.cs#L328-L364","documentation":"PromptSyntaxBuilder.ParseWildcard throws InvalidOperationException when the next token is not scoped 'punctuation.definition.wildcard.begin.prompt' (the '{' that starts a wildcard). Like ParseArray, it assumes the caller verified the token, so this signals a tokenizer/dispatch mismatch.","triggerScenarios":"ParseNode dispatching to ParseWildcard when the consumed token lacks the wildcard-begin scope, or the grammar classifying '{' differently than expected.","commonSituations":"Prompt text with braces used for weighting or non-wildcard syntax, grammar version drift changing scope labels, malformed wildcard templates.","solutions":["Verify the token at the failure point is '{' with scope 'punctuation.definition.wildcard.begin.prompt'.","Update the TextMate grammar scope definitions for wildcard braces.","Correct ParseNode's lookahead so ParseWildcard is only entered after confirming a wildcard-begin token.","Catch the exception at the parse entry point and convert it to a descriptive parse failure."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var tokens = tokenizer.Tokenize(prompt);\nif (tokens.All(t => !t.Scopes.Contains(\"punctuation.definition.wildcard.begin.prompt\")) && prompt.Contains('{'))\n    throw new ArgumentException(\"Prompt contains braces the grammar does not classify as wildcards.\");","typeGuard":"bool IsWildcardBeginToken(Token t) => t?.Scopes?.Contains(\"punctuation.definition.wildcard.begin.prompt\") == true;","tryCatchPattern":"try { var node = builder.Parse(prompt); }\ncatch (InvalidOperationException ex) { ShowUserFriendlyParseError(ex.Message); }","preventionTips":["Document wildcard brace syntax for users of the prompt editor","Test grammar updates against the builder's expected scopes","Escape or reject stray braces in user prompts before parsing"],"tags":["parsing","syntax","wildcard"],"backgroundTag":"internal-invariant-violation","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}