{"record":{"id":"4fd9a2e76fcf83a2","repo":"dotnet/wpf","slug":"invalid-isf-tag-logic","errorCode":null,"errorMessage":"Invalid ISF tag logic","messagePattern":"Invalid ISF tag logic","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/InkSerializer.cs","lineNumber":660,"sourceCode":"                                        // Load the stroke\n                                        Stroke localStroke;\n#if OLD_ISF\n                                        localBytesDecoded = StrokeSerializer.DecodeStroke(inputStream, bytesDecodedInCurrentTag, guidList, strokeDescriptor, currentStylusPointDescription, activeDrawingAttributes, currentTabletToInkTransform, compressor, out localStroke);\n#else\n                                        localBytesDecoded = StrokeSerializer.DecodeStroke(inputStream, bytesDecodedInCurrentTag, guidList, strokeDescriptor, currentStylusPointDescription, activeDrawingAttributes, currentTabletToInkTransform, out localStroke);\n#endif\n\n                                        if (localStroke != null)\n                                        {\n                                            _coreStrokes.AddWithoutEvent(localStroke);\n                                            strokeIndex++;\n                                        }\n                                        break;\n                                    }\n\n                                default:\n                                    {\n                                        throw new InvalidOperationException(ISFDebugMessage(\"Invalid ISF tag logic\"));\n                                    }\n                            }\n\n                            // if this isfTag's decoded size != expected size, then error out\n                            if (localBytesDecoded != bytesDecodedInCurrentTag)\n                            {\n                                throw new ArgumentException(ISFDebugMessage(\"Invalid ISF data\"));\n                            }\n\n                            break;\n                        }\n\n                    case KnownTagCache.KnownTagIndex.Transform:\n                    case KnownTagCache.KnownTagIndex.TransformIsotropicScale:\n                    case KnownTagCache.KnownTagIndex.TransformAnisotropicScale:\n                    case KnownTagCache.KnownTagIndex.TransformRotate:\n                    case KnownTagCache.KnownTagIndex.TransformTranslate:\n                    case KnownTagCache.KnownTagIndex.TransformScaleAndTranslate:","sourceCodeStart":642,"sourceCodeEnd":678,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/InkSerializer.cs#L642-L678","documentation":"The tag switch in DecodeRawISF has a default case that throws InvalidOperationException, meaning the decoder encountered an ISF tag value it has no handler for. Unlike the ArgumentException guards (which detect size/consistency problems), this indicates the tag itself is outside the set the decoder understands — malformed or unsupported ISF data, or an internal logic gap.","triggerScenarios":"Decoding an ISF stream containing a tag not covered by any case in the DecodeRawISF switch (e.g. a newer/proprietary ISF tag, corrupt bytes flipping a tag value, or an unhandled valid tag).","commonSituations":"ISF produced by newer or non-Microsoft ink implementations using tags this WPF version doesn't know; bit-corrupted tag values; loading ISF on an older .NET/WPF version than the writer.","solutions":["Regenerate the ISF with a writer compatible with the consuming WPF version.","Update to a newer .NET/WPF runtime whose decoder handles the tag in question.","Locate the offending tag bytes (compare with a known-good payload) to identify corruption.","Catch InvalidOperationException around DecodeISF and treat the stream as unsupported rather than crashing the app."],"exampleFix":"// before\nvar strokes = StrokeCollectionSerializer.DecodeISF(stream); // unhandled tag crashes\n// after\ntry { var strokes = StrokeCollectionSerializer.DecodeISF(stream); }\ncatch (InvalidOperationException ex) { Log.Warn(\"Unsupported ISF tag\", ex); strokes = new StrokeCollection(); }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return DecodeISF(stream); } catch (InvalidOperationException ex) { logger.Warn(ex, \"Unsupported/unknown ISF tag\"); return new StrokeCollection(); }","preventionTips":["Pin or align the WPF/.NET version between writer and reader of ISF data.","Treat ISF as versioned data; record the producing app/version alongside the blob.","Catch both ArgumentException and InvalidOperationException at decode boundaries.","Sanity-check unknown tag values when debugging corrupt streams."],"tags":["ink","isf","unsupported-tag","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"}