Handle empty Generate Image mode (#2598)

This commit is contained in:
Kirill 2026-06-25 14:59:33 +03:00 committed by GitHub
parent 0e50d32ec5
commit bd4c59cf34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View File

@ -74,6 +74,10 @@ class GenerateImage extends Operation {
Bits: 1 / 8,
};
if (!Object.hasOwn(bytePerPixelMap, mode)) {
throw new OperationError(`Unsupported Mode: (${mode})`);
}
const bytesPerPixel = bytePerPixelMap[mode];
if (bytesPerPixel > 0 && input.length % bytesPerPixel !== 0) {

View File

@ -45,6 +45,17 @@ TestRegister.addTests([
{ op: "Render Image", args: ["Base64"] }
]
},
{
name: "Generate Image: empty mode",
input: "",
expectedOutput: "Unsupported Mode: ()",
recipeConfig: [
{
op: "Generate Image",
args: ["", 8, 64]
}
]
},
{
name: "Extract EXIF: nothing",
input: "",