{"record":{"id":"25c4cc2834123f18","repo":"DioxusLabs/dioxus","slug":"unmatched-closing-in-format-string","errorCode":null,"errorMessage":"unmatched closing '}' in format string","messagePattern":"unmatched closing '\\}' in format string","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"packages/rsx/src/ifmt.rs","lineNumber":197,"sourceCode":"                        }\n                        break;\n                    }\n                    if c == '}' {\n                        segments.push(Segment::Formatted(FormattedSegment {\n                            format_args: String::new(),\n                            segment: FormattedSegmentType::parse(&current_captured)?,\n                        }));\n                        break;\n                    }\n                    current_captured.push(c);\n                }\n            } else {\n                if '}' == c {\n                    if let Some(c) = chars.next_if(|c| *c == '}') {\n                        current_literal.push(c);\n                        continue;\n                    } else {\n                        return Err(Error::new(\n                            Span::call_site(),\n                            \"unmatched closing '}' in format string\",\n                        ));\n                    }\n                }\n                current_literal.push(c);\n            }\n        }\n\n        if !current_literal.is_empty() {\n            segments.push(Segment::Literal(current_literal));\n        }\n\n        Ok(segments)\n    }\n}\n\nimpl ToTokens for IfmtInput {","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/rsx/src/ifmt.rs#L179-L215","documentation":"Error from dioxus's inline format string parser (ifmt) used for formatted text like `div { \"Hello {name}\" }`. Inside RSX string literals `{` starts and `}` ends an interpolation; a lone `}` in the literal portion is invalid and must be doubled (`}}`), exactly like Rust std format strings.","triggerScenarios":"A single `}` appearing in the literal part of an RSX formatted string, e.g. `div { \"list: {items}\" }` mis-typed as `div { \"} items\" }`, or CSS/JSON snippets like `\"body { color: red }\"` where the closing brace is not escaped as `}}`.","commonSituations":"Rendering CSS fragments, JSON, or code samples containing braces; un-escaping a format! string when moving it into rsx; hand-editing templates after hot-reload iterations.","solutions":["Escape the brace: replace the literal `}` with `}}` (and `{` with `{{`) inside the string","Move brace-heavy text into a variable outside rsx and interpolate it: `\"{css_text}\"`"],"exampleFix":"// before\nrsx! { p { \"json { value: 1 }\" } }\n\n// after\nrsx! { p { \"json {{ value: 1 }}\" } }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat RSX string literals like format! strings: always write literal braces as {{ and }}","Run cargo check after editing templates with braces (CSS, JSON) to catch escaping early","Keep brace-heavy static text in constants outside rsx and interpolate them"],"tags":["rsx","ifmt","format-string","escaping","compile-time"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}