{"record":{"id":"655fdd4588d2ce7a","repo":"SixLabors/ImageSharp","slug":"invalid-name1-or-name2-message-was-value1-and-value2","errorCode":null,"errorMessage":"Invalid {name1} or {name2}. {message}. Was '{value1}' and '{value2}'.","messagePattern":"Invalid (.+?) or (.+?)\\. (.+?)\\. Was '(.+?)' and '(.+?)'\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Formats/Png/PngThrowHelper.cs","lineNumber":47,"sourceCode":"    [DoesNotReturn]\n    public static void ThrowMissingPalette() => throw new InvalidImageContentException(\"PNG Image does not contain a palette chunk.\");\n\n    [DoesNotReturn]\n    public static void ThrowInvalidChunkType() => throw new InvalidImageContentException(\"Invalid PNG data.\");\n\n    [DoesNotReturn]\n    public static void ThrowInvalidChunkType(string message) => throw new InvalidImageContentException(message);\n\n    [DoesNotReturn]\n    public static void ThrowInvalidChunkCrc(string chunkTypeName) => throw new InvalidImageContentException($\"CRC Error. PNG {chunkTypeName} chunk is corrupt!\");\n\n    [DoesNotReturn]\n    public static void ThrowInvalidParameter(object value, string message, [CallerArgumentExpression(nameof(value))] string name = \"\")\n        => throw new NotSupportedException($\"Invalid {name}. {message}. Was '{value}'.\");\n\n    [DoesNotReturn]\n    public static void ThrowInvalidParameter(object value1, object value2, string message, [CallerArgumentExpression(nameof(value1))] string name1 = \"\", [CallerArgumentExpression(nameof(value2))] string name2 = \"\")\n        => throw new NotSupportedException($\"Invalid {name1} or {name2}. {message}. Was '{value1}' and '{value2}'.\");\n\n    [DoesNotReturn]\n    public static void ThrowNotSupportedColor() => throw new NotSupportedException(\"Unsupported PNG color type.\");\n\n    [DoesNotReturn]\n    public static void ThrowUnknownFilter() => throw new InvalidImageContentException(\"Unknown filter type.\");\n}\n","sourceCodeStart":29,"sourceCodeEnd":55,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Formats/Png/PngThrowHelper.cs#L29-L55","documentation":"The two-parameter overload of PngThrowHelper.ThrowInvalidParameter throws NotSupportedException reading 'Invalid {name1} or {name2}. {message}. Was {value1} and {value2}.' It is used when a combination of two decoded PNG chunk fields is jointly invalid even though either alone might be plausible. Like the single-value overload, the parameter names come from CallerArgumentExpression, so the message shows the exact decoded fields.","triggerScenarios":"Decoding a PNG/APNG where two related frame-control fields are inconsistent — concretely FrameControl.XOffset + Width exceeding the main PngHeader.Width, checked at src/ImageSharp/Formats/Png/Chunks/FrameControl.cs:117.","commonSituations":"Malformed APNG frame geometry from broken encoders; corrupted or partially-written animation files; hand-edited binary PNG chunks; fuzzed test corpora.","solutions":["Read both values in the message and check the PNG's fcTL chunk geometry with a validator such as pngcheck -v.","Re-encode the animation with a standards-compliant APNG encoder so frames fit within the declared canvas.","Wrap decode in try/catch for NotSupportedException and surface a 'corrupt animation' error to end users.","If you control generation of these files, add encoder-side assertions that xOffset + width <= canvas width."],"exampleFix":"// before\nusing var image = Image.Load(\"broken.apng\");\n// after\ntry\n{\n    using var image = Image.Load(\"broken.apng\");\n}\ncatch (NotSupportedException ex)\n{\n    throw new InvalidDataException($\"APNG frame geometry invalid: {ex.Message}\", ex);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { using var img = await Image.LoadAsync(stream); }\ncatch (NotSupportedException ex) { throw new InvalidDataException($\"APNG frame geometry invalid: {ex.Message}\", ex); }","preventionTips":["Validate APNG frame geometry (xOffset + width <= canvas width) at encode time.","Use pngcheck -v on animation files before batch processing.","Quarantine files that fail rather than retrying decode.","Keep ImageSharp current for the latest chunk-validation behavior."],"tags":["png","apng","image-decoding","malformed-input"],"backgroundTag":"invalid-argument-value","analyzedSha":"59ce6af6fc29027cda277ef62d4d1694a8acce91","analyzedAt":"2026-09-13T18:34:59.331Z","contentChangedAt":"2026-09-13T18:34:59.331Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}