{"record":{"id":"f9b6687d3e5b799f","repo":"LykosAI/StabilityMatrix","slug":"expected-network-weight","errorCode":null,"errorMessage":"Expected network weight.","messagePattern":"Expected network weight\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Models/PromptSyntax/PromptSyntaxBuilder.cs","lineNumber":273,"sourceCode":"        var nameToken = PeekToken();\n        if (nameToken is null || !nameToken.Scopes.Contains(\"meta.embedded.network.model.prompt\"))\n            throw new InvalidOperationException(\"Expected network name.\");\n        var name = ParseText();\n\n        // model weight, clip weight\n        NumberNode? modelWeight = null;\n        NumberNode? clipWeight = null;\n\n        // colon\n        var nextToken = PeekToken();\n        if (nextToken is not null && nextToken.Scopes.Contains(\"punctuation.separator.variable.prompt\"))\n        {\n            ConsumeToken(); // consume colon\n\n            // Parse the model weight.\n            var modelWeightToken = ConsumeToken();\n            if (modelWeightToken is null || !modelWeightToken.Scopes.Contains(\"constant.numeric\"))\n                throw new InvalidOperationException(\"Expected network weight.\");\n            modelWeight = ParseNumber();\n\n            // colon\n            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 (","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Models/PromptSyntax/PromptSyntaxBuilder.cs#L255-L291","documentation":"Thrown by ParseNetwork when parsing the optional model weight: after a second ':' the parser consumes a token that must be scoped 'constant.numeric'. If the token is missing or not numeric, it throws 'Expected network weight.' This covers the first (model) weight slot in '<lora:name:0.8:0.6>'.","triggerScenarios":"Input like '<lora:name:abc>' where the model weight is non-numeric, or '<lora:name:>' where the weight is absent after the second colon.","commonSituations":"Weights written as text ('strong', 'high') instead of numbers; locale-formatted decimals with commas ('0,8'); truncated tags where the numeric part was cut off.","solutions":["Supply a numeric weight: '<lora:name:0.8>'","Use '.' as the decimal separator, not ','","Omit the second colon entirely if no weight is intended: '<lora:name>'","Catch InvalidOperationException and validate tag weights before parsing"],"exampleFix":"// before\nvar prompt = \"<lora:myModel:0,8>\";\n// after\nvar prompt = \"<lora:myModel:0.8>\";","handlingStrategy":"validation","validationCode":"bool HasNumericWeights(string tag) { var m = System.Text.RegularExpressions.Regex.Matches(tag, \":([0-9]*\\.?[0-9]+)\"); return m.Count > 0; } // all weight slots are ASCII decimals","typeGuard":"null","tryCatchPattern":"try { var node = builder.Parse(prompt); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"network weight\")) { // prompt user to fix the weight value }","preventionTips":["Use digits with '.' decimal separators for weights","Omit the weight colon entirely rather than leaving it empty","Normalize locale-formatted numbers ('0,8' -> '0.8') before parsing","Generate tags programmatically with float formatting invariant culture"],"tags":["parser","prompt-syntax","lora","weight","numeric-token"],"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"}