phalcon/cphalcon · error · Phalcon\Acl\Exceptions\InvalidComponentImplementation

Object passed as componentName must implement Phalcon\Acl\Co

Error message

Object passed as componentName must implement Phalcon\Acl\ComponentAwareInterface or Phalcon\Acl\ComponentInterface

What it means

BeanstalkConnection maps beanstalkd's 'BAD_FORMAT' reply to an exception: the command line sent to the server violated the protocol grammar. The client formats commands internally, so the realistic trigger is invalid arguments injected into a command — most commonly tube names containing characters outside the byte range beanstalkd allows for tube names.

Source

Thrown at phalcon/Acl/Adapter/Memory.zep:1113

            access . "' for '" . componentName . "'."
        );
    }

    /**
     * Resolves a component identifier (object or string) to its name
     */
    private function toComponentName(var component)
    {
        if typeof component === "object" {
            if component instanceof ComponentAwareInterface {
                return component->getComponentName();
            }

            if component instanceof ComponentInterface {
                return component->getName();
            }

            throw new InvalidComponentImplementation();
        }

        return component;
    }

    /**
     * Resolves a role identifier (object or string) to its name
     */
    private function toRoleName(var role)
    {
        if typeof role === "object" {
            if role instanceof RoleAwareInterface {
                return role->getRoleName();
            }

            if role instanceof RoleInterface {
                return role->getName();
            }

View on GitHub (pinned to b7419de9cd)

Solutions

  1. Restrict tube names to safe characters — practically [A-Za-z0-9._+-] with no spaces.
  2. Sanitize dynamic names before use: preg_replace('/[^A-Za-z0-9._+-]/', '', $name).
  3. If all arguments are known-good, treat BAD_FORMAT as a desync symptom: recreate the connection.

Example fix

// before
$queue->watch('incoming orders'); // space breaks the command line -> BAD_FORMAT

// after
$tube = preg_replace('/[^A-Za-z0-9._+-]/', '-', 'incoming orders'); // 'incoming-orders'
$queue->watch($tube);
Defensive patterns

Strategy: validation

Validate before calling

function sanitizeTubeName(string $name): string
{
    $safe = preg_replace('/[^A-Za-z0-9._+-]/', '-', $name);
    if ($safe === '') {
        throw new \InvalidArgumentException('Tube name cannot be empty');
    }
    return $safe;
}

$queue->watch(sanitizeTubeName($userSuppliedTube));

Prevention

When it happens

Trigger: Calling watch()/use()-style operations (or any command whose args you supply) with a tube name containing spaces or special characters, e.g. 'my tube!', so the rendered command line fails the server's parser.

Common situations: User- or config-supplied tube names; dynamically composed names from slugs that kept forbidden characters; copying tube names from other systems with different naming rules.

Related errors


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/53b0a5a580a0be44. Report an issue: GitHub.