{"record":{"id":"f23bfde3188bed2e","repo":"stride3d/stride","slug":"tag-value-must-not-be-empty","errorCode":null,"errorMessage":"Tag value must not be empty.","messagePattern":"Tag value must not be empty\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Events/NodeEvent.cs","lineNumber":105,"sourceCode":"        protected NodeEvent(string anchor, string tag, Mark start, Mark end)\n            : base(start, end)\n        {\n            if (anchor != null)\n            {\n                if (anchor.Length == 0)\n                {\n                    throw new ArgumentException(\"Anchor value must not be empty.\", \"anchor\");\n                }\n\n                if (!anchorValidator.IsMatch(anchor))\n                {\n                    throw new ArgumentException(\"Anchor value must contain alphanumerical characters only.\", \"anchor\");\n                }\n            }\n\n            if (tag != null && tag.Length == 0)\n            {\n                throw new ArgumentException(\"Tag value must not be empty.\", \"tag\");\n            }\n\n            this.anchor = anchor;\n            this.tag = tag;\n        }\n\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"NodeEvent\"/> class.\n        /// </summary>\n        protected NodeEvent(string anchor, string tag)\n            : this(anchor, tag, Mark.Empty, Mark.Empty)\n        {\n        }\n    }\n}","sourceCodeStart":87,"sourceCodeEnd":120,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Events/NodeEvent.cs#L87-L120","documentation":"NodeEvent's constructor validates optional anchor and tag strings. A tag (the type identifier like !!str or !custom) may be null but must not be a zero-length string; an empty tag means the YAML producer emitted a malformed node property. The library throws ArgumentException to fail fast rather than propagate a corrupt event into the parser/emitter pipeline.","triggerScenarios":"Calling the NodeEvent constructor (directly or via an event emitter) with tag: \"\" — e.g. building YamlStream events programmatically or forwarding a tag parsed from a fragment that had '!!' or '!' with nothing after it.","commonSituations":"Programmatic YAML document construction, string-splitting a tag directive like '!!str' on '!!' and passing the empty remainder, templating engines that substitute an empty value for a tag placeholder.","solutions":["Check that the tag string is null or non-empty before constructing the NodeEvent","If a node has no tag, pass null instead of the empty string","Trim and validate the tag came from a complete tag property (e.g. '!!str' not a bare '!!')"],"exampleFix":"// before\nvar evt = new NodeEvent(anchor, tag: \"\", ...);\n// after\nvar evt = new NodeEvent(anchor, tag: string.IsNullOrEmpty(rawTag) ? null : rawTag, ...);","handlingStrategy":"validation","validationCode":"if (tag != null && tag.Length == 0) throw new ArgumentException(\"tag must be null or non-empty\"); var evt = new NodeEvent(anchor, tag, ...);","typeGuard":"static bool IsValidTag(string tag) => tag == null || tag.Length > 0;","tryCatchPattern":"try { var evt = new NodeEvent(anchor, tag); } catch (ArgumentException ex) when (ex.ParamName == \"tag\") { /* fall back to null tag */ }","preventionTips":["Pass null (not \"\") when a node has no tag","Validate tag tokens after splitting tag strings on '!'","Unit-test programmatic event construction with edge-case tags"],"tags":["yaml","argument-validation","empty-string"],"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"}