{"record":{"id":"5b41a8368d7327a3","repo":"abpframework/abp","slug":"incorrect-syntax-at-char-i-these-is-no-opening","errorCode":null,"errorMessage":"Incorrect syntax at char {i}! These is no opening brackets for the closing bracket }.","messagePattern":"Incorrect syntax at char (.+?)! These is no opening brackets for the closing bracket \\}\\.","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Core/Volo/Abp/Text/Formatting/FormatStringTokenizer.cs","lineNumber":39,"sourceCode":"                case '{':\n                    if (inDynamicValue)\n                    {\n                        throw new FormatException(\"Incorrect syntax at char \" + i + \"! format string can not contain nested dynamic value expression!\");\n                    }\n\n                    inDynamicValue = true;\n\n                    if (currentText.Length > 0)\n                    {\n                        tokens.Add(new FormatStringToken(currentText.ToString(), FormatStringTokenType.ConstantText));\n                        currentText.Clear();\n                    }\n\n                    break;\n                case '}':\n                    if (!inDynamicValue)\n                    {\n                        throw new FormatException(\"Incorrect syntax at char \" + i + \"! These is no opening brackets for the closing bracket }.\");\n                    }\n\n                    inDynamicValue = false;\n\n                    if (currentText.Length <= 0)\n                    {\n                        throw new FormatException(\"Incorrect syntax at char \" + i + \"! Brackets does not containt any chars.\");\n                    }\n\n                    var dynamicValue = currentText.ToString();\n                    if (includeBracketsForDynamicValues)\n                    {\n                        dynamicValue = \"{\" + dynamicValue + \"}\";\n                    }\n\n                    tokens.Add(new FormatStringToken(dynamicValue, FormatStringTokenType.DynamicValue));\n                    currentText.Clear();\n","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Core/Volo/Abp/Text/Formatting/FormatStringTokenizer.cs#L21-L57","documentation":"While tokenizing a format string, a '}' is read when inDynamicValue is false (no preceding '{' opened a dynamic segment). The tokenizer treats '}' exclusively as the close of a dynamic value, so a stray closing brace with no matching open is a syntax error and throws FormatException. Used internally by FormattedStringValueExtracter.Extract/IsMatch.","triggerScenarios":"Calling FormattedStringValueExtracter.Extract(str, format) with a format whose first brace character is '}': \"} text\", \"a}b\", or \"name}suffix\". Any '}' encountered before any '{' triggers it (test case at FormattedStringTokenizer_Test.cs:15 tokenizes \"} wrong format\").","commonSituations":"Config or template strings with an unbalanced closing brace (typo, truncated copy-paste); JSON/code-snippet templates pasted as formats where '}' survived from an object literal; format strings built by concatenation that dropped the opening '{'.","solutions":["Remove the stray '}' or pair it with a matching '{...}' dynamic segment.","Add a brace-balance validation pass over the format before calling Extract and reject/sanitize unbalanced templates.","Catch FormatException around Extract when the format is user-supplied and treat it as a non-match."],"exampleFix":"// before: stray closing brace, no opening brace\nvar r = FormattedStringValueExtracter.Extract(input, \"user} profile\");\n// throws FormatException: no opening bracket for the closing }\n\n// after: drop the brace, or open a proper dynamic segment\nvar r = FormattedStringValueExtracter.Extract(input, \"user profile\");\n// or: var r = FormattedStringValueExtracter.Extract(input, \"{name} profile\");","handlingStrategy":"try-catch","validationCode":"static bool HasBalancedBraces(string format)\n{\n    if (format.IsNullOrEmpty()) return true;\n    var depth = 0;\n    foreach (var c in format)\n    {\n        if (c == '{') depth++;\n        else if (c == '}')\n        {\n            if (depth == 0) return false; // stray closing brace\n            depth--;\n        }\n    }\n    return depth == 0;\n}\n\nif (!HasBalancedBraces(format)) { /* reject template */ }","typeGuard":null,"tryCatchPattern":"try\n{\n    result = FormattedStringValueExtracter.Extract(str, format);\n}\ncatch (FormatException)\n{\n    result = new ExtractionResult(false); // treat malformed format as non-match\n}","preventionTips":["Run a brace-balance check on every template when it is loaded from config.","Never build formats by naive concatenation of fragments that may each contain braces.","Unit-test format templates with sample inputs before shipping.","Keep format strings in constants so typos surface at compile/review time."],"tags":["formatting","format-string","parsing","tokenization","formatted-string"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}