{"record":{"id":"cdc650466f4a6b3c","repo":"dotnet/wpf","slug":"tag-is-outside-of-the-known-guid-tag-range","errorCode":null,"errorMessage":"Tag is outside of the known guid tag range","messagePattern":"Tag is outside of the known guid tag range","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/GuidTagList.cs","lineNumber":113,"sourceCode":"                tag = FindCustomTag(guid);\n                if (KnownTagCache.KnownTagIndex.Unknown == tag)\n                    tag = FindKnownTag(guid);\n            }\n\n            return tag;\n        }\n\n\n        /// <summary>\n        /// Finds a known guid based on a Tag\n        /// </summary>\n        /// <param name=\"tag\"></param>\n        /// <returns></returns>\n        private static Guid FindKnownGuid(KnownTagCache.KnownTagIndex tag)\n        {\n            if (tag < KnownIdCache.KnownGuidBaseIndex)\n            {\n                throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage(\"Tag is outside of the known guid tag range\"));\n            }\n\n            // Get the index in the OriginalISFIdTable array first\n            uint nIndex = (uint)(tag - KnownIdCache.KnownGuidBaseIndex);\n\n            // If invalid, return Guid.Empty\n            if (KnownIdCache.OriginalISFIdTable.Length <= nIndex)\n                return Guid.Empty;\n\n            // Otherwise, return the guid\n            return KnownIdCache.OriginalISFIdTable[nIndex];\n        }\n\n\n        /// <summary>\n        /// Finds a Custom Guid based on a Tag\n        /// </summary>\n        /// <param name=\"tag\"></param>","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/GuidTagList.cs#L95-L131","documentation":"FindKnownGuid converts a known ISF tag to a .NET Guid but only for tags in the 'known guid' range (>= KnownIdCache.KnownGuidBaseIndex). When a tag below that base index reaches it, the tag is not a valid known guid tag, so the ISF serializer throws ArgumentException with this ISF debug message.","triggerScenarios":"Decoding an ISF stream whose tag byte/uint encodes a tag that falls below KnownGuidBaseIndex - i.e. a corrupt, truncated, or hand-crafted ISF payload, or a caller passing an invalid KnownTagCache.KnownTagIndex into guid/FindGuid.","commonSituations":"Parsing ISF files produced by third-party tools, clipboard ink data that was mangled in transit, or unit tests feeding arbitrary tag values into the ISF decoder.","solutions":["Verify the ISF stream is complete and uncorrupted before decoding (check stream length and header).","Confirm the data was produced by a compatible ISF writer version; regenerate the ISF payload.","Validate the KnownTagCache.KnownTagIndex value is >= KnownIdCache.KnownGuidBaseIndex before calling FindGuid/guid.","Wrap DecodeAsISF/StrokeCollection construction in a try-catch for ArgumentException and treat the stream as invalid."],"exampleFix":"// before\nGuid g = KnownTags.FindGuid(tag); // throws for bad tag\n// after\nif ((int)tag >= KnownIdCache.KnownGuidBaseIndex)\n{\n    Guid g = KnownTags.FindGuid(tag);\n}\nelse\n{\n    // skip unknown tag or fail gracefully\n}","handlingStrategy":"validation","validationCode":"bool IsValidKnownTag(KnownTagCache.KnownTagIndex t) => (int)t >= (int)KnownIdCache.KnownGuidBaseIndex;","typeGuard":"static bool IsValidKnownTag(KnownTagCache.KnownTagIndex tag) => tag >= KnownIdCache.KnownGuidBaseIndex;","tryCatchPattern":"try { Guid g = KnownTags.FindGuid(tag); }\ncatch (ArgumentException ex) { Log(ex); return Guid.Empty; }","preventionTips":["Range-check tags before FindGuid calls","Only decode ISF from trusted, verified sources","Reject streams that fail header validation"],"tags":["ink","isf","serialization","argument-exception"],"backgroundTag":"value-out-of-range","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}