{"record":{"id":"6d3dc55c2179c335","repo":"stride3d/stride","slug":"tag-handle-must-not-be-empty","errorCode":null,"errorMessage":"Tag handle must not be empty.","messagePattern":"Tag handle must not be empty\\.","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Tokens/TagDirective.cs","lineNumber":96,"sourceCode":"            : this(handle, prefix, Mark.Empty, Mark.Empty)\n        {\n        }\n\n        private static readonly Regex tagHandleValidator = new Regex(@\"^!([0-9A-Za-z_\\-]*!)?$\");\n\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"TagDirective\"/> class.\n        /// </summary>\n        /// <param name=\"handle\">The handle.</param>\n        /// <param name=\"prefix\">The prefix.</param>\n        /// <param name=\"start\">The start position of the token.</param>\n        /// <param name=\"end\">The end position of the token.</param>\n        public TagDirective(string handle, string prefix, Mark start, Mark end)\n            : base(start, end)\n        {\n            if (string.IsNullOrEmpty(handle))\n            {\n                throw new ArgumentNullException(\"handle\", \"Tag handle must not be empty.\");\n            }\n\n            if (!tagHandleValidator.IsMatch(handle))\n            {\n                throw new ArgumentException(\"Tag handle must start and end with '!' and contain alphanumerical characters only.\", \"handle\");\n            }\n\n            this.handle = handle;\n\n            if (string.IsNullOrEmpty(prefix))\n            {\n                throw new ArgumentNullException(\"prefix\", \"Tag prefix must not be empty.\");\n            }\n\n            this.prefix = prefix;\n        }\n\n        /// <summary>","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Tokens/TagDirective.cs#L78-L114","documentation":"The TagDirective token constructor throws ArgumentNullException (with a descriptive message) when the YAML %TAG directive's handle is null or empty. A tag handle is the short prefix like '!' or '!e!'; without it the directive is meaningless so the library rejects it eagerly at token construction time.","triggerScenarios":"Parsing a YAML document containing a %TAG directive with an empty handle (e.g. `%TAG ! <>` with an empty handle field), or constructing a TagDirective directly with null/empty handle.","commonSituations":"Hand-edited YAML config files with malformed %TAG directives; template-generated YAML where a tag placeholder was left empty; programmatic YAML emission bugs.","solutions":["Correct the %TAG directive in the YAML source so it has a non-empty handle (e.g. `!e!`).","If constructing programmatically, validate `!string.IsNullOrEmpty(handle)` before `new TagDirective(...)`.","Remove the %TAG directive if tag shorthand is not needed and use full tag URIs instead."],"exampleFix":"// before (YAML)\n%TAG ! <>\n---\nfoo: bar\n// after (YAML)\n%TAG !e! tag:example.com,2000:\n---\nfoo: bar","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(handle))\n    throw new ArgumentException(\"%TAG directive requires a non-empty handle.\");\nvar token = new TagDirective(handle, prefix, start, end);","typeGuard":"static bool IsValidTagHandle(string h) => !string.IsNullOrEmpty(h);","tryCatchPattern":"try { return new TagDirective(handle, prefix, start, end); }\ncatch (ArgumentNullException ex) { throw new YamlSyntaxException($\"Malformed %TAG directive: {ex.Message}\", start); }","preventionTips":["Lint YAML files for %TAG directives before deployment.","Validate handles against ^![0-9A-Za-z]*!$ when generating YAML.","Avoid hand-editing %TAG lines without re-parsing the document."],"tags":["yaml","null-argument","directive"],"backgroundTag":"empty-required-field","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"}