{"record":{"id":"73a6b1e562bdeb8e","repo":"Intervention/image","slug":"no-decoders-in-array","errorCode":null,"errorMessage":"No decoders in array","messagePattern":"No decoders in array","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Drivers/AbstractDriver.php","lineNumber":59,"sourceCode":"    {\n        return $this->config;\n    }\n\n    /**\n     * {@inheritdoc}\n     *\n     * @see DriverInterface::decodeImage()\n     *\n     * @throws InvalidArgumentException\n     * @throws ImageDecoderException\n     * @throws DriverException\n     */\n    public function decodeImage(mixed $input, ?array $decoders = null): ImageInterface\n    {\n        $decoders = $decoders === null ? InputHandler::IMAGE_DECODERS : $decoders;\n\n        if (count($decoders) === 0) {\n            throw new InvalidArgumentException('No decoders in array');\n        }\n\n        try {\n            $result = InputHandler::usingDecoders($decoders, $this)->handle($input);\n        } catch (NotSupportedException) {\n            $type = is_object($input) ? $input::class : gettype($input);\n            throw new InvalidArgumentException('Unsupported image source type \"' . $type . '\"');\n        }\n\n        if (!$result instanceof ImageInterface) {\n            throw new ImageDecoderException('Result must be instance of ' . ImageInterface::class);\n        }\n\n        return $result;\n    }\n\n    /**\n     * {@inheritdoc}","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/AbstractDriver.php#L41-L77","documentation":"AbstractDriver::decodeImage() requires a non-empty list of image input decoders. When no explicit list is passed it uses the built-in InputHandler::IMAGE_DECODERS chain, so this exception can only fire when a custom decoders array was passed and it is empty.","triggerScenarios":"Calling $driver->decodeImage($input, []) with an explicitly empty decoders array, e.g. a dynamically filtered list that removed every decoder.","commonSituations":"Apps building custom decoder chains by filtering InputHandler::IMAGE_DECODERS at runtime (e.g. disabling file-path decoding) and accidentally filtering everything.","solutions":["Pass null to use the default decoder chain","Ensure a dynamically built decoder array is non-empty before calling decodeImage()"],"exampleFix":"// before\n$decoders = array_filter($all, fn ($d) => $d->supportsStreaming());\n$image = $driver->decodeImage($input, array_values($decoders)); // may be []\n\n// after\n$image = $decoders === []\n    ? $driver->decodeImage($input)\n    : $driver->decodeImage($input, array_values($decoders));","handlingStrategy":"validation","validationCode":"if ($decoders === []) {\n    $decoders = null; // fall back to the default chain\n}\n$image = $driver->decodeImage($input, $decoders);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass a possibly-empty custom decoder array; pass null instead","Assert count($decoders) > 0 after runtime filtering"],"tags":["decoder","driver","configuration"],"backgroundTag":"empty-decoder-chain","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}