Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Result::getFirstError can return false even if Result::hasErrors is true #3370

Open
mhsdesign opened this issue Jun 21, 2024 · 0 comments

Comments

@mhsdesign
Copy link
Member

mhsdesign commented Jun 21, 2024

State of the result in question

Flow Variable Dump
Neos\Error\Messages\Result object
 errors => array(empty)
 errorsExist => true
 warnings => array(empty)
 warningsExist => false
 notices => array(empty)
 noticesExist => false
 propertyResults => array(1)
   integer 0 => Neos\Error\Messages\Result object
     errors => array(1)
       integer 0 => Neos\Flow\Property\TypeConverter\Error\TargetNotFoundError prototype object proxy
     errorsExist => true
     warnings => array(empty)
     warningsExist => false
     notices => array(empty)
     noticesExist => false
     propertyResults => array(empty)
     parent => Neos\Error\Messages\Result object
 parent => NULL

The following code breaks with this exception, and after debugging it turns out getFirstError really returns false.

Error: Call to a member function getMessage() on bool

$propertyValue = $this->propertyMapper->convert(...);
$messages = $this->propertyMapper->getMessages();
if ($messages->hasErrors()) {
    throw new \RuntimeException($messages->getFirstError()->getMessage(), 1718976491);
}

This seems to be a workaround to really get the first error:

$flattenedErrors = $messages->getFlattenedErrors();
$firstError = current(current($flattenedErrors));

I think this is because we set errorsExist on the parent but the error i inside the propertyResults sub result.
Maybe this is how it is and im using it wrongly.

Tested on

Flow 7.3
Flow 8.3

mhsdesign added a commit to Flowpack/Flowpack.NodeTemplates that referenced this issue Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant