LykosAI/StabilityMatrix · error · InvalidOperationException
Expected opening brace.
Error message
Expected opening brace.
What it means
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.
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.
Defensive patterns
Strategy: try-catch
Validate before calling
var tokens = tokenizer.Tokenize(prompt);
if (tokens.All(t => !t.Scopes.Contains("punctuation.definition.wildcard.begin.prompt")) && prompt.Contains('{'))
throw new ArgumentException("Prompt contains braces the grammar does not classify as wildcards."); Type guard
bool IsWildcardBeginToken(Token t) => t?.Scopes?.Contains("punctuation.definition.wildcard.begin.prompt") == true; Try / catch
try { var node = builder.Parse(prompt); }
catch (InvalidOperationException ex) { ShowUserFriendlyParseError(ex.Message); } Prevention
- 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
When it happens
Trigger: ParseNode dispatching to ParseWildcard when the consumed token lacks the wildcard-begin scope, or the grammar classifying '{' differently than expected.
Common situations: Prompt text with braces used for weighting or non-wildcard syntax, grammar version drift changing scope labels, malformed wildcard templates.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Fields line not found
- Invalid RIFF header
- Invalid Token
- Invalid WEBP header
- The 'Name' key was not found in the pip show output.
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/9c670853c483b923.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Core/Models/PromptSyntax/PromptSyntaxBuilder.cs:346
break;
}
else
{
node.Elements.Add(ParseNode()); // Recursively parse nested nodes.
}
}
return node;
}
private WildcardNode ParseWildcard()
{
var openBraceToken = ConsumeToken(); // Consume the '{'
if (
openBraceToken is null
|| !openBraceToken.Scopes.Contains("punctuation.definition.wildcard.begin.prompt")
)
throw new InvalidOperationException("Expected opening brace.");
var node = new WildcardNode
{
Span = new TextSpan(openBraceToken.StartIndex, 0), // Set start index
};
while (MoreTokens())
{
var nextToken = PeekToken();
if (nextToken is null)
break;
if (nextToken.Scopes.Contains("punctuation.definition.wildcard.end.prompt"))
{
ConsumeToken(); // Consume the '}'
node.EndIndex = nextToken.EndIndex;
break;
}View on GitHub (pinned to af93d6ef57)