{"record":{"id":"2278bc8932731466","repo":"stride3d/stride","slug":"while-parsing-a-block-mapping-did-not-find-expected-key","errorCode":null,"errorMessage":"While parsing a block mapping, did not find expected key.","messagePattern":"While parsing a block mapping, did not find expected key\\.","errorType":"exception","errorClass":"SemanticErrorException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Parser.cs","lineNumber":712,"sourceCode":"                else\n                {\n                    state = ParserState.YAML_PARSE_BLOCK_MAPPING_VALUE_STATE;\n                    return ProcessEmptyScalar(mark);\n                }\n            }\n\n            else if (GetCurrentToken() is BlockEnd)\n            {\n                state = states.Pop();\n                Event evt = new Events.MappingEnd(GetCurrentToken().Start, GetCurrentToken().End);\n                Skip();\n                return evt;\n            }\n\n            else\n            {\n                var current = GetCurrentToken();\n                throw new SemanticErrorException(current.Start, current.End, \"While parsing a block mapping, did not find expected key.\");\n            }\n        }\n\n        /// <summary>\n        /// Parse the productions:\n        /// block_mapping        ::= BLOCK-MAPPING_START\n        ///\n        ///                          ((KEY block_node_or_indentless_sequence?)?\n        ///\n        ///                          (VALUE block_node_or_indentless_sequence?)?)*\n        ///                           ***** *\n        ///                          BLOCK-END\n        ///\n        /// </summary>\n        private Event ParseBlockMappingValue()\n        {\n            if (GetCurrentToken() is Value)\n            {","sourceCodeStart":694,"sourceCodeEnd":730,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Parser.cs#L694-L730","documentation":"Stride.Core.Yaml's parser reached a position inside a block mapping where the next token is not a valid key (e.g. a scalar or tag where 'key:' was expected). The parser builds block mappings from BLOCK-MAPPING-START/KEY tokens produced by the scanner; when ParseBlockMappingKey sees a token that cannot be a key it aborts with this SemanticErrorException.","triggerScenarios":"Parsing a YAML document where a block mapping entry is malformed: missing colon after a key, a value appearing at the wrong indentation, or a non-scalar token (anchor, tag, alias) where a key is required.","commonSituations":"Hand-edited config files with a forgotten ':' after a key, copy-pasted YAML where indentation shifted so a value sits where a key should be, or keys written with invalid characters for plain scalars.","solutions":["Check the reported line/column and add the missing ':' after the key","Verify indentation of all lines in the block mapping is consistent (spaces, not tabs)","Quote keys containing special characters (:, -, ?, {, etc.) so the scanner emits a scalar token","Validate the YAML with a linter (yamllint) before loading"],"exampleFix":"// before\nconfig:\n  enabled true\n// after\nconfig:\n  enabled: true","handlingStrategy":"try-catch","validationCode":"// Pre-validate with a lenient parse\ntry { new YamlStream().Load(new StringReader(yamlText)); } catch (YamlException) { /* reject before real use */ }","typeGuard":"bool LooksLikeYamlMapping(string line) => !string.IsNullOrWhiteSpace(line) && (line.Contains(\": \") || line.TrimEnd().EndsWith(\":\"));","tryCatchPattern":"try { var yaml = new YamlStream(); yaml.Load(reader); } catch (YamlException ex) { logger.LogError(ex, \"YAML syntax error at {Line}:{Col}\", ex.Start.Line, ex.Start.Column); throw new ConfigFormatException(ex.Start.Line, ex.Start.Column, ex.Message); }","preventionTips":["Run yamllint or an editor YAML plugin on files before loading","Use consistent 2/4-space indentation, never tabs","Quote keys containing special characters","Keep keys and their ':' on the same line"],"tags":["yaml","parser","syntax"],"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-15T23:17:13.987Z"}