{"record":{"id":"bf2e23eefe6a486a","repo":"dotnet/wpf","slug":"invalid-pentip-value-found-in-isf-stream","errorCode":null,"errorMessage":"Invalid PenTip value found in ISF stream","messagePattern":"Invalid PenTip value found in ISF stream","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/DrawingAttributeSerializer.cs","lineNumber":154,"sourceCode":"\n                maximumStreamSize -= cb;\n\n                // Get the guid based on the tag\n                Guid guid = guidList.FindGuid (tag);\n                if (guid == Guid.Empty)\n                {\n                    throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage(\"Drawing Attribute tag embedded in ISF stream does not match guid table\"));\n                }\n\n                uint dw = 0;\n\n                if (KnownIds.PenTip == guid)\n                {\n                    cb = SerializationHelper.Decode (stream, out dw);\n                    penTip = (PenTip)dw;\n                    if (!PenTipHelper.IsDefined(penTip))\n                    {\n                        throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage(\"Invalid PenTip value found in ISF stream\"));\n                    }\n                    maximumStreamSize -= cb;\n                }\n                else if (KnownIds.PenStyle == guid)\n                {\n                    cb = SerializationHelper.Decode(stream, out dw);\n                    penStyle = (PenStyle)dw;\n                    maximumStreamSize -= cb;\n                }\n                else if (KnownIds.DrawingFlags == guid)\n                {\n                    // Encode the drawing flags with considerations for v2 model\n                    cb = SerializationHelper.Decode (stream, out dw);\n                    DrawingFlags flags = (DrawingFlags)dw;\n                    da.DrawingFlags = flags;\n                    maximumStreamSize -= cb;\n                }\n                else if (KnownIds.RasterOperation == guid)","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/DrawingAttributeSerializer.cs#L136-L172","documentation":"When the decoded guid is KnownIds.PenTip, DecodeAsISF reads the raw uint and casts it to PenTip. If the value is not a defined PenTip member (checked via PenTipHelper.IsDefined), the stream is deemed invalid and ArgumentException is thrown. This guards enum integrity when reading ISF.","triggerScenarios":"Decoding ISF whose PenTip field contains an out-of-range uint — data written by a newer WPF with enum values this version doesn't know, a corrupt stream, or hand-crafted bytes.","commonSituations":"Forward-compatibility problems (newer PenTip values like the custom tip read by older runtimes); corrupt files; third-party ISF generators writing arbitrary ints.","solutions":["Upgrade to a WPF/.NET version that defines the PenTip value in the stream","Validate/repair the ISF source; re-save from the original application","Catch the exception and fall back to default PenTip for that attribute","Sanitize PenTip values in any third-party ISF producer"],"exampleFix":"// before\nvar attrs = DecodeAttributes(stream); // throws on unknown PenTip\n// after\ntry { var attrs = DecodeAttributes(stream); }\ncatch (ArgumentException)\n{\n    attrs = new DrawingAttributes(); // defaults; log the invalid stream\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { attrs = DecodeDrawingAttributes(stream, guidList, maxSize); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"PenTip\")) { attrs = new DrawingAttributes(); /* default fallback */ }","preventionTips":["Keep .NET/WPF versions aligned between writers and readers","Sanitize enum values in any custom ISF producer","Round-trip test PenTip serialization on every enum change","Never write raw ints into PenTip fields without IsDefined checks"],"tags":["wpf","ink","isf","enum","deserialization"],"backgroundTag":"invalid-enum-value","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"}