{"record":{"id":"63ad5aa2698c9805","repo":"stride3d/stride","slug":"found-duplicate-tag-directive","errorCode":null,"errorMessage":"Found duplicate %TAG directive.","messagePattern":"Found duplicate %TAG directive\\.","errorType":"exception","errorClass":"SemanticErrorException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Parser.cs","lineNumber":333,"sourceCode":"                if ((currentVersion = GetCurrentToken() as VersionDirective) != null)\n                {\n                    if (version != null)\n                    {\n                        throw new SemanticErrorException(currentVersion.Start, currentVersion.End, \"Found duplicate %YAML directive.\");\n                    }\n\n                    if (currentVersion.Version.Major != Constants.MajorVersion || currentVersion.Version.Minor != Constants.MinorVersion)\n                    {\n                        throw new SemanticErrorException(currentVersion.Start, currentVersion.End, \"Found incompatible YAML document.\");\n                    }\n\n                    version = currentVersion;\n                }\n                else if ((tag = GetCurrentToken() as TagDirective) != null)\n                {\n                    if (tagDirectives.Contains(tag.Handle))\n                    {\n                        throw new SemanticErrorException(tag.Start, tag.End, \"Found duplicate %TAG directive.\");\n                    }\n                    tagDirectives.Add(tag);\n                    if (tags != null)\n                    {\n                        tags.Add(tag);\n                    }\n                }\n                else\n                {\n                    break;\n                }\n\n                Skip();\n            }\n\n            if (tags != null)\n            {\n                AddDefaultTagDirectives(tags);","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Parser.cs#L315-L351","documentation":"Each %TAG directive handle (e.g. !e!) may be declared only once per document. If ProcessDirectives sees a TagDirective whose handle is already in the document's tag directive collection, it throws SemanticErrorException at the duplicate's span.","triggerScenarios":"A document declaring the same handle twice, e.g. \"%TAG !e! tag:example.com,2000:\\n%TAG !e! tag:other:\\n---\"; or a generator appending default tag directives to input that already defines them.","commonSituations":"Templated YAML where includes each carry the same %TAG header, concatenating documents' directive blocks.","solutions":["Remove the duplicate %TAG directive or rename one of the handles (e.g. use !e2!)","Deduplicate tag directives when merging YAML fragments","In generators, only emit default %TAG directives when the handle isn't already declared"],"exampleFix":"// before\n%TAG !e! tag:example.com,2000:\n%TAG !e! tag:other:\n---\n// after\n%TAG !e! tag:example.com,2000:\n%TAG !e2! tag:other:\n---","handlingStrategy":"validation","validationCode":"var seen = new HashSet<string>();\nforeach (var line in File.ReadLines(path))\n    if (line.StartsWith(\"%TAG \") && !seen.Add(line.Split(' ')[1]))\n        throw new InvalidDataException($\"Duplicate %TAG handle: {line.Split(' ')[1]}\");","typeGuard":null,"tryCatchPattern":"try { stream.Load(reader); } catch (SemanticErrorException ex) when (ex.Message.Contains(\"duplicate %TAG\")) { /* deduplicate directives and retry */ }","preventionTips":["Use distinct handles for distinct tag prefixes","Deduplicate %TAG headers when merging fragments","Generators: skip default %TAG emission if already present"],"tags":["yaml","directive","duplicate","tag"],"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"}