{"record":{"id":"1982eece720d19e4","repo":"filamentphp/filament","slug":"block-of-class-blockclass-must-have-a-unique-na","errorCode":null,"errorMessage":"Block of class [$blockClass] must have a unique name, passed to the [make()] method.","messagePattern":"Block of class \\[\\$blockClass\\] must have a unique name, passed to the \\[make\\(\\)\\] method\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"packages/forms/src/Components/Builder/Block.php","lineNumber":38,"sourceCode":"    use HasName;\n\n    protected string | BackedEnum | Htmlable | Closure | null $icon = null;\n\n    protected int | Closure | null $maxItems = null;\n\n    final public function __construct(string $name)\n    {\n        $this->name($name);\n    }\n\n    public static function make(?string $name = null): static\n    {\n        $blockClass = static::class;\n\n        $name ??= static::getDefaultName();\n\n        if (blank($name)) {\n            throw new InvalidArgumentException(\"Block of class [$blockClass] must have a unique name, passed to the [make()] method.\");\n        }\n\n        $static = app($blockClass, ['name' => $name]);\n        $static->configure();\n\n        return $static;\n    }\n\n    public static function getDefaultName(): ?string\n    {\n        return null;\n    }\n\n    public function icon(string | BackedEnum | Htmlable | Closure | null $icon): static\n    {\n        $this->icon = $icon;\n\n        return $this;","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/filamentphp/filament/blob/53483fa9340e4ec637985fe454ebb58afb92ea24/packages/forms/src/Components/Builder/Block.php#L20-L56","documentation":"Builder blocks are identified by name — it becomes the block type key stored in the builder's JSON state. `Block::make()` falls back to `getDefaultName()` (null on the base class) and throws an InvalidArgumentException when the resolved name is blank, before the block can be registered in a `Builder` schema.","triggerScenarios":"`Block::make()` with no argument in a block class that does not override `getDefaultName()`, or `Block::make($key)` where `$key` is null/empty when the builder schema is constructed.","commonSituations":"Custom block classes where the author assumed auto-naming, registering blocks from a plugin config array with a missing key, or copy-pasted blocks with the name removed.","solutions":["Pass an explicit unique name: `Block::make('hero')`.","In custom block classes, override `getDefaultName()` to return a stable non-blank identifier.","Guard dynamic registration: skip or default blocks whose configured key is blank."],"exampleFix":"// before\nBuilder::make('content')->blocks([\n    Block::make()->schema([...]),\n]);\n\n// after\nBuilder::make('content')->blocks([\n    HeroBlock::make('hero')->schema([...]),\n]);","handlingStrategy":"type-guard","validationCode":"foreach ($blockConfigs as $key => $config) {\n    if (blank($key)) {\n        continue;\n    }\n\n    $blocks[] = $blockClass::make($key)->schema($config['schema'] ?? []);\n}","typeGuard":"function assertBlockName(?string $name): string\n{\n    if (blank($name)) {\n        throw new InvalidArgumentException('Builder block name cannot be blank.');\n    }\n\n    return $name;\n}\n\n// Block::make(assertBlockName($key))","tryCatchPattern":null,"preventionTips":["Override getDefaultName() in reusable block classes with a stable identifier.","Treat blank keys in plugin config arrays as configuration errors and validate them at load time.","Block names become JSON keys — keep them stable to avoid orphaned content."],"tags":["filament","builder","forms","schema","component-name"],"backgroundTag":"missing-component-name","analyzedSha":"53483fa9340e4ec637985fe454ebb58afb92ea24","analyzedAt":"2026-08-17T02:06:23.049Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}