Issue Bug Accepted Quiet

#98190Extbase fails to resolve chained validations

Oliver Hader 08/23/22, 12:51 updated 11/01/26, 18:01

Description

use TYPO3\CMS\Extbase\Annotation\Validate;

class Parent extends AbstractEntity
{
  protected Child $child;
}

class Child extends AbstractEntity
{
  /**
   * @Validate("StringLength", options={"minimum": 1, "maximum": 80})
   */
  public string $title = '';
}

class ParentController extends ActionController
{
  public function showAction(Parent $parent): ResponseInterface
  {
    // ...
  }
}

Action Parent.show gets argument of type Parent, which has a non-accessible property to type Child, which has a validation rule of a property. Following the validation chain is correct in general, unless some part of it cannot be accessed (which is protected property Parent::$child in this example).

The result is a corresponding exception:

(1/1) #1546632293 RuntimeException
Could not get value of property "Olly\Model\Domain\Model\Parent::child",
make sure the property is either public or has a getter getChild(), a hasser hasChild() or an isser isChild().

In case validation for internal values is desired/expected, this probably would be something for reflection.
In case developers would “need to adjust their code”, current RuntimeException (#1546632293) is semantically wrong, it has to be a LogicException instead.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Fix this issue

Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch

Commit message
[BUGFIX] Extbase fails to resolve chained validations Resolves: #98190 Releases: main

History 4

  1. Georg Ringer commented <span data-processor="relativetime" data-value="2026-11-01T18:01:16+00:00" > 11/01/26, 18:01 </span>

    Still reproducible on main (15.0.0-dev, fd25ec1e9e6): a protected model-typed property without accessor, whose class has validators, throws RuntimeException #1546632293 from AbstractGenericObjectValidator::getPropertyValue(). Checked by calling ValidatorResolver::getBaseValidatorConjunction()->validate() directly, not through a full request.

    Since this report, there are explicit ways to opt out:

    • #[IgnoreValidation] on the property (main only, #111134)
    • #[Transient] (main, 14.3 and 13.4, #91727; deprecated for this purpose on main)

    Adding a getter also avoids the exception. The default case is unchanged, and the exception is still a RuntimeException.

    Open question: is the exception the intended behaviour now that #[IgnoreValidation] exists? If so, this could be reduced to changing the exception type and pointing to the attribute in its message. Skipping inaccessible properties silently would drop validation that fails loudly today.