{"record":{"id":"94a0ea2923464ced","repo":"stride3d/stride","slug":"while-parsing-a-tag-did-not-find-uri-escaped-octet","errorCode":null,"errorMessage":"While parsing a tag, did not find URI escaped octet.","messagePattern":"While parsing a tag, did not find URI escaped octet\\.","errorType":"exception","errorClass":"SyntaxErrorException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Scanner.cs","lineNumber":2163,"sourceCode":"            return tag.ToString();\n        }\n\n        /// <summary>\n        /// Decode an URI-escape sequence corresponding to a single UTF-8 character.\n        /// </summary>\n        private char ScanUriEscapes(Mark start)\n        {\n            // Decode the required number of characters.\n\n            List<byte> charBytes = new List<byte>();\n            int width = 0;\n            do\n            {\n                // Check for a URI-escaped octet.\n\n                if (!(analyzer.Check('%') && analyzer.IsHex(1) && analyzer.IsHex(2)))\n                {\n                    throw new SyntaxErrorException(start, mark, \"While parsing a tag, did not find URI escaped octet.\");\n                }\n\n                // Get the octet.\n\n                int octet = (analyzer.AsHex(1) << 4) + analyzer.AsHex(2);\n\n                // If it is the leading octet, determine the length of the UTF-8 sequence.\n\n                if (width == 0)\n                {\n                    width = (octet & 0x80) == 0x00 ? 1 :\n                        (octet & 0xE0) == 0xC0 ? 2 :\n                            (octet & 0xF0) == 0xE0 ? 3 :\n                                (octet & 0xF8) == 0xF0 ? 4 : 0;\n\n                    if (width == 0)\n                    {\n                        throw new SyntaxErrorException(start, mark, \"While parsing a tag, find an incorrect leading UTF-8 octet.\");","sourceCodeStart":2145,"sourceCodeEnd":2181,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Scanner.cs#L2145-L2181","documentation":"Inside Scanner.ScanTagUri, a '%' starts a URI-escaped octet in a tag, but the two following characters were not hex digits (e.g. '%G1' or '%' at end of input). Valid URI escapes in YAML tags must be exactly %XX with hex digits, so the scanner throws SyntaxErrorException.","triggerScenarios":"Parsing a tag containing an invalid percent-escape, e.g. '!%zzfoo' or '!foo%2' — the character after '%' is not hex, or fewer than two characters remain.","commonSituations":"Tags containing literal percent signs that were not percent-encoded (e.g. Windows paths like '!C:\\100%done'); hand-built tag URIs with truncated escapes; URL-encoding applied incorrectly to tag suffixes.","solutions":["Percent-encode '%' in the tag as '%25', e.g. '!100%25done'.","Ensure every '%' in the tag is followed by exactly two hex digits (%2F, %3A, ...).","Remove unintended '%' characters from the tag name.","Catch SyntaxErrorException and report the mark to locate the bad escape."],"exampleFix":"// before (input.yaml)\nname: !100%error\n\n// after (input.yaml)\nname: !100%25error","handlingStrategy":"validation","validationCode":"// C#\nforeach (System.Text.RegularExpressions.Match m in System.Text.RegularExpressions.Regex.Matches(yamlText, \"%..\"))\n{\n    var hex = m.Value.Substring(1);\n    if (!byte.TryParse(hex, System.Globalization.NumberStyles.HexNumber, null, out _))\n        throw new FormatException($\"Invalid URI escape %{hex} in YAML tag.\");\n}","typeGuard":null,"tryCatchPattern":"try { deserializer.Deserialize(reader, targetType); }\ncatch (SyntaxErrorException ex) { throw new YamlConfigException($\"Invalid % escape in tag at line {ex.Start.Line}\", ex); }","preventionTips":["Percent-encode literal '%' as %25 in tag URIs.","Generate tags with Uri.EscapeDataString instead of manual string building.","Keep tag names ASCII-alphanumeric to sidestep escaping rules."],"tags":["yaml","parsing","uri-encoding"],"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-23T08:17:48.524Z"}