{"record":{"id":"f95364f612cbeb58","repo":"dotnet/wpf","slug":"inkserializedformat-operation-failed","errorCode":null,"errorMessage":"InkSerializedFormat operation failed.","messagePattern":"InkSerializedFormat operation failed\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/AlgoModule.cs","lineNumber":150,"sourceCode":"            }\n\n            // compression / algo data always goes in index 0\n            compressedData[0] = compression;\n            return compressedData.ToArray();\n        }\n\n        /// <summary>\n        /// DecompressPacketData - given a compressed byte[], uncompress it to the outputBuffer\n        /// </summary>\n        /// <param name=\"input\">compressed byte from the ISF stream</param>\n        /// <param name=\"outputBuffer\">prealloc'd buffer to write to</param>\n        /// <returns></returns>\n        internal uint DecompressPacketData(byte[] input, int[] outputBuffer)\n        {\n            ArgumentNullException.ThrowIfNull(input);\n            if (input.Length < 2)\n            {\n                throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage(\"Input buffer passed was shorter than expected\"));\n            }\n            ArgumentNullException.ThrowIfNull(outputBuffer);\n            if (outputBuffer.Length == 0)\n            {\n                throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage(\"output buffer length was zero\"));\n            }\n\n            byte compression = input[0];\n            uint totalBytesRead = 1; //we just read one\n            int inputIndex = 1;\n            switch (compression & 0xC0)\n            {\n                case 0x80://IndexedHuffman\n                    {\n                        DataXform dtxf = this.HuffModule.FindDtXf(compression);\n                        HuffCodec huffCodec = this.HuffModule.FindCodec(compression);\n                        totalBytesRead += huffCodec.Uncompress(dtxf, input, inputIndex, outputBuffer);\n                        return totalBytesRead;","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/AlgoModule.cs#L132-L168","documentation":"AlgoModule.DecompressPacketData decompresses Ink Serialized Format (ISF) packet data. It validates the inputs first: a null input buffer throws ArgumentNullException, surfaced by the caller as a generic 'InkSerializedFormat operation failed' ArgumentException context — here the first guard (input null) corresponds to the line-150 region. It indicates ISF packet data being decompressed is missing or null.","triggerScenarios":"Calling DecompressPacketData (directly or via ISF deserialization of a stroke collection) with a null input byte array, i.e. corrupt or absent packet data.","commonSituations":"Loading truncated or malformed .isf / ink streams; deserializing ink embedded in documents where the packet-data attribute is missing.","solutions":["Ensure the input byte[] is non-null and comes from a complete ISF stream","Validate ISF data integrity before deserialization (stream fully read, length > 0)","Catch ArgumentException around deserialization and treat the ink as unreadable","Re-export or re-save the ink data from the source application"],"exampleFix":"// before\nalgo.DecompressPacketData(readBuffer, outBuffer);\n// after\nif (readBuffer != null && readBuffer.Length >= 2) algo.DecompressPacketData(readBuffer, outBuffer); else throw new InvalidDataException(\"ISF packet data missing\");","handlingStrategy":"validation","validationCode":"if (input == null) throw new ArgumentNullException(nameof(input));\nif (input.Length < 2) throw new InvalidDataException(\"ISF packet data missing or truncated\");","typeGuard":"static bool ValidPacketInput(byte[] b) => b != null && b.Length >= 2;","tryCatchPattern":"try { algo.DecompressPacketData(input, output); }\ncatch (ArgumentException ex) { throw new InvalidDataException(\"Corrupt ISF packet data\", ex); }","preventionTips":["Ensure ISF streams are read to completion before decompression","Validate packet-data attributes exist before deserializing ink","Wrap ISF deserialization to convert low-level ArgumentExceptions into corrupt-data errors"],"tags":["wpf","ink","isf","argument-validation"],"backgroundTag":"invalid-argument-format","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"}