filamentphp/filament · error · LogicException

Action name at index [{$actionNestingIndex}] is not specifie

Error message

Action name at index [{$actionNestingIndex}] is not specified.

What it means

Filament's action-testing helpers normalize their `$actions` argument through `parseNestedActions()`: it accepts a dot string (`'edit.approve'`), a `TestAction`, or an array stack of entries where each entry is a string, `TestAction`, or an array that must contain a `'name'` key. Any array entry without `'name'` throws a LogicException naming the offending nesting index before the test interaction runs.

Source

Thrown at packages/actions/src/Testing/TestsActions.php:720

            } elseif (
                ($actions instanceof TestAction) ||
                array_key_exists('name', $actions)
            ) {
                $actions = [$actions];
            }

            $areArgumentsKeyedByActionName = false;

            foreach ($actions as $actionNestingIndex => $action) {
                if (is_string($action)) {
                    $action = [
                        'name' => $action,
                    ];
                } elseif ($action instanceof TestAction) {
                    $action = $action->toArray(defaultSchema: ($initialMountedActionsCount + $actionNestingIndex) ? ('mountedActionSchema' . ($initialMountedActionsCount + $actionNestingIndex - 1)) : $this->instance()->getDefaultTestingSchemaName());
                }

                $actionName = $action['name'] ?? throw new LogicException("Action name at index [{$actionNestingIndex}] is not specified.");

                if (
                    class_exists($actionName) &&
                    ($actionClassNameAttributes = (new ReflectionClass($actionName))->getAttributes(ActionName::class))
                ) {
                    $action['name'] = $actionName = (string) Arr::first($actionClassNameAttributes)->newInstance();
                }

                if (
                    class_exists($actionName) &&
                    is_subclass_of($actionName, Action::class)
                ) {
                    $action['name'] = $actionName = $actionName::getDefaultName();
                }

                if (filled($arguments) && (! array_key_exists('arguments', $action))) {
                    if (array_key_exists($actionName, $arguments)) {
                        $action['arguments'] = $arguments[$actionName];

View on GitHub (pinned to 53483fa934)

Solutions

  1. Add a `'name'` key to every array entry: `['name' => 'approve', 'arguments' => [...]]`.
  2. Use a dot string for simple nesting (`'edit.approve'`) or a `TestAction` object instead of raw arrays.
  3. For class-based actions, pass the FQCN — it is resolved through its `ActionName` attribute or `getDefaultName()`.

Example fix

// before
$this->callAction([['name' => 'edit'], ['arguments' => ['id' => 1]]]);

// after
$this->callAction([['name' => 'edit'], ['name' => 'approve', 'arguments' => ['id' => 1]]]);
Defensive patterns

Strategy: validation

Validate before calling

// Normalize before calling a testing helper
$normalized = array_map(
    fn (string|array|TestAction $action): array => match (true) {
        is_string($action) => ['name' => $action],
        $action instanceof TestAction => $action->toArray(),
        default => $action,
    },
    $actions,
);

foreach ($normalized as $index => $action) {
    if (! isset($action['name'])) {
        throw new InvalidArgumentException("Test action at index [{$index}] is missing 'name'.");
    }
}

Type guard

function isValidTestActionSpec(mixed $action): bool
{
    return is_string($action)
        || $action instanceof TestAction
        || (is_array($action) && array_key_exists('name', $action));
}

Try / catch

try {
    $this->callAction($actions);
} catch (LogicException $exception) {
    $this->fail('Malformed action spec: ' . $exception->getMessage());
}

Prevention

When it happens

Trigger: Calling a testing helper like `callAction([...])` or `mountAction([...])` with an array entry such as `['arguments' => ['id' => 1]]` that is missing the `'name'` key (also caused by using the wrong key, e.g. `'action'`).

Common situations: Writing Pest/PHPUnit tests for nested mounted modal actions, data-provided test payloads where a record drops the name field, or refactoring a string spec into arrays and forgetting the key.

Related errors


AI-assisted analysis of filamentphp/filament@53483fa934 (2026-08-17). Data as JSON: /api/errors/96a41d6f4461139a. Report an issue: GitHub.