{"record":{"id":"10aefc288ce2fae3","repo":"stride3d/stride","slug":"while-scanning-a-plain-scalar-find-unexpected","errorCode":null,"errorMessage":"While scanning a plain scalar, find unexpected ':'.","messagePattern":"While scanning a plain scalar, find unexpected ':'\\.","errorType":"exception","errorClass":"SyntaxErrorException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Scanner.cs","lineNumber":1846,"sourceCode":"                {\n                    break;\n                }\n\n                // Check for a comment.\n\n                if (analyzer.Check('#'))\n                {\n                    break;\n                }\n\n                // Consume non-blank characters.\n                while (!analyzer.IsBlankOrBreakOrZero())\n                {\n                    // Check for 'x:x' in the flow context. TODO: Fix the test \"spec-08-13\".\n\n                    if (flowLevel > 0 && analyzer.Check(':') && !analyzer.IsBlankOrBreakOrZero(1))\n                    {\n                        throw new SyntaxErrorException(start, mark, \"While scanning a plain scalar, find unexpected ':'.\");\n                    }\n\n                    // Check for indicators that may end a plain scalar.\n\n                    if ((analyzer.Check(':') && analyzer.IsBlankOrBreakOrZero(1)) || (flowLevel > 0 && analyzer.Check(\",:?[]{}\")))\n                    {\n                        break;\n                    }\n\n                    // Check if we need to join whitespaces and breaks.\n\n                    if (hasLeadingBlanks || whitespaces.Length > 0)\n                    {\n                        if (hasLeadingBlanks)\n                        {\n                            // Do we need to fold line breaks?\n\n                            if (StartsWith(leadingBreak, '\\n'))","sourceCodeStart":1828,"sourceCodeEnd":1864,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Scanner.cs#L1828-L1864","documentation":"Thrown by the YAML Scanner while scanning a plain (unquoted) scalar when a ':' appears in a position where it would be ambiguous or illegal — specifically inside flow context ({}, []) when the colon is not followed by a blank/break, or a colon elsewhere in a spot that terminates the scalar incorrectly. YAML only allows ':' in plain scalars under strict conditions, and this input violates them.","triggerScenarios":"Parsing YAML containing a plain scalar with 'key:value' (no space after colon) inside a flow collection, e.g. {a:b: c}, or any plain scalar where a ':' is followed by a non-space in flow context.","commonSituations":"Users writing JSON-ish '{url:http://example.com}' in YAML; URLs containing ':' inside flow sequences without quoting; values copied from JSON that rely on JSON's looser colon rules.","solutions":["Quote the offending scalar with double or single quotes so ':' is allowed anywhere inside it.","Add a space after the colon if it was meant as a mapping separator, e.g. {a: b} instead of {a:b}.","Rewrite the flow collection as block-style mappings, which have more lenient colon handling.","Validate the document with a YAML parser before feeding it to the application."],"exampleFix":"// before\nurls: [http://example.com, http://other.org]\n// after\nurls: [\"http://example.com\", \"http://other.org\"]","handlingStrategy":"try-catch","validationCode":"// Detect 'x:y' inside flow context before parsing\nbool HasColonInFlowScalar(string yaml) =>\n    System.Text.RegularExpressions.Regex.IsMatch(yaml, \"\\\\{[^}]*[a-zA-Z0-9]:[^\\\\s}]\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var obj = new Deserializer().Deserialize<ObjectT>(yamlReader);\n}\ncatch (SyntaxErrorException ex)\n{\n    Log.Error(ex, \"Unexpected ':' in plain scalar at line {Line}, col {Col}\", ex.Start.Line, ex.Start.Column);\n    throw;\n}","preventionTips":["Always quote scalars containing ':' (URLs, times, key:value strings) inside flow collections","Use block-style YAML rather than JSON-like flow style when values contain colons","Round-trip YAML through the library when generating it instead of string concatenation"],"tags":["yaml","scanner","plain-scalar","flow-context"],"backgroundTag":"yaml-parse-error","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}