{"record":{"id":"48953a6ca77d843a","repo":"LorisYounger/VPet","slug":"invalid-fdat-chunk","errorCode":null,"errorMessage":"Invalid fdAT chunk.","messagePattern":"Invalid fdAT chunk\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"VPet-Simulator.Core/Graph/APNGAnimation.cs","lineNumber":311,"sourceCode":"                                Width = result.CanvasWidth,\n                                Height = result.CanvasHeight,\n                                XOffset = 0,\n                                YOffset = 0,\n                                DelayNum = 1,\n                                DelayDen = 10,\n                                DisposeOp = 0,\n                                BlendOp = 0,\n                            };\n                            result.Frames.Add(currentFrame);\n                        }\n                        currentFrame.ImageDataChunks.Add(data);\n                        break;\n                    case \"fdAT\":\n                        imageDataStarted = true;\n                        if (currentFrame == null)\n                            throw new InvalidDataException(\"fdAT found before fcTL.\");\n                        if (data.Length < 4)\n                            throw new InvalidDataException(\"Invalid fdAT chunk.\");\n                        byte[] idatData = new byte[data.Length - 4];\n                        Buffer.BlockCopy(data, 4, idatData, 0, idatData.Length);\n                        currentFrame.ImageDataChunks.Add(idatData);\n                        break;\n                    case \"IEND\":\n                        return result;\n                    default:\n                        if (!imageDataStarted)\n                        {\n                            result.SharedChunks.Add(new PngChunk { Type = type, Data = data });\n                        }\n                        break;\n                }\n            }\n\n            return result;\n        }\n","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/LorisYounger/VPet/blob/ffb9cc2a856244a0f91aa5ecf10d097bcdd4954f/VPet-Simulator.Core/Graph/APNGAnimation.cs#L293-L329","documentation":"An fdAT chunk must carry at least a 4-byte sequence number; ParseApng throws InvalidDataException when the chunk data is shorter than 4 bytes because there is no payload left to extract as image data.","triggerScenarios":"Loading an APNG whose fdAT chunk is truncated below its mandatory sequence-number size.","commonSituations":"Truncated downloads; corruption from bad chunk editing; files written by encoders that emit empty fdAT chunks.","solutions":["Re-download or re-export the APNG with valid fdAT chunks (apngasm/ffmpeg).","Run a PNG chunk validator to locate the malformed chunk.","Replace the asset with a rebuild of the animation from source frames.","Remove/skip the corrupt asset."],"exampleFix":"// before\nnew APNGAnimation(\"truncated.png\"); // fdAT < 4 bytes\n// after\n// apngasm -o fixed.png frames/*.png\nnew APNGAnimation(\"fixed.png\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { var anim = new APNGAnimation(path); } catch (InvalidDataException ex) when (ex.Message.Contains(\"Invalid fdAT\")) { Log.Error($\"truncated APNG: {path}\"); ReDownloadAsset(path); }","preventionTips":["Verify file size/hash after download; reject truncated files","Use binary-safe transfer for .png assets","Rebuild animations from frames rather than editing chunks"],"tags":["png","apng","malformed-data"],"backgroundTag":"file-read-failed","analyzedSha":"ffb9cc2a856244a0f91aa5ecf10d097bcdd4954f","analyzedAt":"2026-09-15T21:21:10.398Z","contentChangedAt":"2026-09-15T21:21:10.398Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}