{"record":{"id":"fcb420faadab9ec3","repo":"laravel/framework","slug":"unsupported-binary-codec-format-s-allowed-form","errorCode":null,"errorMessage":"Unsupported binary codec format [%s]. Allowed formats are: %s.","messagePattern":"Unsupported binary codec format \\[(.+?)\\]\\. Allowed formats are: (.+?)\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Eloquent/Casts/AsBinary.php","lineNumber":32,"sourceCode":"     *\n     * @param  array{string}  $arguments\n     * @return \\Illuminate\\Contracts\\Database\\Eloquent\\CastsAttributes\n     *\n     * @throws \\InvalidArgumentException\n     */\n    public static function castUsing(array $arguments)\n    {\n        return new class($arguments) implements CastsAttributes\n        {\n            protected string $format;\n\n            public function __construct(protected array $arguments)\n            {\n                $this->format = $this->arguments[0]\n                    ?? throw new InvalidArgumentException('The binary codec format is required.');\n\n                if (! in_array($this->format, BinaryCodec::formats(), true)) {\n                    throw new InvalidArgumentException(sprintf(\n                        'Unsupported binary codec format [%s]. Allowed formats are: %s.',\n                        $this->format,\n                        implode(', ', BinaryCodec::formats()),\n                    ));\n                }\n            }\n\n            public function get($model, $key, $value, $attributes)\n            {\n                return BinaryCodec::decode($attributes[$key] ?? null, $this->format);\n            }\n\n            public function set($model, $key, $value, $attributes)\n            {\n                return [$key => BinaryCodec::encode($value, $this->format)];\n            }\n        };\n    }","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/Eloquent/Casts/AsBinary.php#L14-L50","documentation":"Thrown by AsBinary cast's constructor when the supplied format is not in BinaryCodec::formats(). The default allowed formats are 'uuid' and 'ulid' (plus any custom codecs registered with BinaryCodec). Any other string (typos like 'guid', 'binary', 'uuidv4') is rejected at model boot with the allowed list included in the message.","triggerScenarios":"Declaring 'column' => AsBinary::class.':guid' or any format string other than uuid/ulid; using a format name that was meant to be registered as a custom codec but wasn't; typo in the cast declaration.","commonSituations":"Guessing a format name; renaming from a previous version's format; forgetting to register a custom codec before using it in a cast.","solutions":["Use one of the built-in formats: 'uuid' or 'ulid'.","If you need a custom encoding, register it first via Illuminate\\Support\\BinaryCodec (add a custom codec) so BinaryCodec::formats() includes your name, then declare AsBinary::class.':<yourformat>'.","Fix typos in the cast string (the format is everything after the colon).","Inspect the exact allowed list at runtime: \\Illuminate\\Support\\BinaryCodec::formats()."],"exampleFix":"// before\nprotected $casts = ['id' => AsBinary::class.':guid'];\n\n// after\nprotected $casts = ['id' => AsBinary::class.':uuid'];","handlingStrategy":"validation","validationCode":"if (! in_array($format, \\Illuminate\\Support\\BinaryCodec::formats(), true)) {\n    throw new \\InvalidArgumentException(\n        'Format must be one of: '.implode(', ', \\Illuminate\\Support\\BinaryCodec::formats())\n    );\n}","typeGuard":"function isValidBinaryFormat(string $format): bool {\n    return in_array($format, \\Illuminate\\Support\\BinaryCodec::formats(), true);\n}","tryCatchPattern":null,"preventionTips":["Use only 'uuid' or 'ulid' for the AsBinary cast unless you registered a custom codec.","Register custom codecs via Illuminate\\Support\\BinaryCodec before referencing them in casts.","Assert allowed formats at boot with a test that checks model casts against BinaryCodec::formats()."],"tags":["database","eloquent","casts","uuid","laravel"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}