{"record":{"id":"812c7d001cc3d0b2","repo":"stride3d/stride","slug":"incompatible-yaml-directive","errorCode":null,"errorMessage":"Incompatible %YAML directive","messagePattern":"Incompatible %YAML directive","errorType":"exception","errorClass":"YamlException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Emitter.cs","lineNumber":834,"sourceCode":"                else\n                {\n                    throw new YamlException(\"Duplicate %TAG directive.\");\n                }\n            }\n            else\n            {\n                tagDirectives.Add(value);\n            }\n        }\n\n        /// <summary>\n        /// Check if a %YAML directive is valid.\n        /// </summary>\n        private static void AnalyzeVersionDirective(VersionDirective versionDirective)\n        {\n            if (versionDirective.Version.Major != Constants.MajorVersion || versionDirective.Version.Minor != Constants.MinorVersion)\n            {\n                throw new YamlException(\"Incompatible %YAML directive\");\n            }\n        }\n\n        private void WriteIndicator(string indicator, bool needWhitespace, bool whitespace, bool indentation)\n        {\n            if (needWhitespace && !isWhitespace)\n            {\n                Write(' ');\n            }\n\n            Write(indicator);\n\n            isWhitespace = whitespace;\n            isIndentation &= indentation;\n            isOpenEnded = false;\n        }\n\n        private void WriteIndent()","sourceCodeStart":816,"sourceCodeEnd":852,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Emitter.cs#L816-L852","documentation":"The emitter only supports emitting YAML matching the version constants compiled into the library (MajorVersion/MinorVersion, i.e. YAML 1.1). A %YAML directive declaring a different version is rejected by Emitter.AnalyzeVersionDirective with this YamlException.","triggerScenarios":"Emitting a DocumentStart event whose VersionDirective declares a %YAML 1.2 (or any major/minor other than the library's supported pair) while the emitter writes the document stream.","commonSituations":"Parsing YAML 1.2 documents elsewhere and re-emitting them with Stride.Core.Yaml; copy-pasting %YAML 1.2 headers from specs or other tools; upgrading a pipeline that standardized on YAML 1.2.","solutions":["Remove the %YAML directive from the emitted document so the emitter writes its default version","Change the VersionDirective to the version the library supports (check Stride.Core.Yaml Constants.MajorVersion/MinorVersion)","Pre-process input files to rewrite %YAML 1.2 to the supported version before emitting","Use a YAML 1.2-capable emitter if 1.2 output is mandatory"],"exampleFix":"// before\nnew DocumentStart(new VersionDirective(new Version(1, 2)), null, true);\n// after\nnew DocumentStart(new VersionDirective(new Version(1, 1)), null, true);","handlingStrategy":"validation","validationCode":"bool ok = versionDirective == null || (versionDirective.Version.Major == 1 && versionDirective.Version.Minor == 1);\nif (!ok) throw new InvalidOperationException(\"Only YAML 1.1 %YAML directive is supported by this emitter\");","typeGuard":null,"tryCatchPattern":"try { emitter.Emit(docStart); }\ncatch (YamlException ex) when (ex.Message.Contains(\"Incompatible %YAML\")) { /* drop or rewrite the VersionDirective and retry */ }","preventionTips":["Omit the %YAML directive unless a specific version is required","Never carry a parsed %YAML 1.2 directive over into re-emitted output","Pin toolchains to one YAML version"],"tags":["yaml","serialization","version"],"backgroundTag":"unsupported-yaml-version","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"}