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

exception message is wrong and misleading in findAccessorMethodName() of Magento\Framework\Reflection\NameFinder #9764

Closed
dbsdsun opened this issue May 26, 2017 · 3 comments
Assignees
Labels
bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@dbsdsun
Copy link

dbsdsun commented May 26, 2017

Preconditions

  1. Magento 2.1.2

Steps to reproduce

  1. This function gets getter name. and It call findAccessorMethodName()
    

public function getGetterMethodName(ClassReflection $class, $camelCaseProperty)
{
$getterName = 'get' . $camelCaseProperty;
$boolGetterName = 'is' . $camelCaseProperty;
return $this->findAccessorMethodName($class, $camelCaseProperty, $getterName, $boolGetterName);
}

  1. In my case, 
           $getterName = getIsDefaultBilling
           $class->name = "Magento\Customer\Api\Data\AddressInterface"
    
  2. Obviously, Magento is looking for a getter in findAccessorMethodName()
    

    When there is no getter, findAccessorMethodName() generates an exception with message:
    ' ... does not have corresponding setter in class ... '

    This exception is wrong and misleading.

Expected result

  1. In findAccessorMethodName() of Magento\Framework\Reflection\NameFinder, the exception message should be
         throw new \LogicException(
             sprintf(
                 'Property "%s" does not have accessor method "%s" in class "%s".',
                 $camelCaseProperty,
                 $accessorName,
                 $class->getName()
             )
         );
    

Actual result

  1. [Screenshot, logs]
    

"message": "Property "IsDefaultBilling" does not have corresponding setter in class "Magento\Customer\Api\Data\AddressInterface".",
trace":
#0 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Reflection\NameFinder.php(59): Magento\Framework\Reflection\NameFinder->findAccessorMethodName(Object(Zend\Code\Reflection\ClassReflection), 'IsDefaultBillin...', 'getIsDefaultBil...', 'isIsDefaultBill...')

#1 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Webapi\ServiceInputProcessor.php(158): Magento\Framework\Reflection\NameFinder->getGetterMethodName(Object(Zend\Code\Reflection\ClassReflection), 'IsDefaultBillin...')

#2 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Webapi\ServiceInputProcessor.php(318): Magento\Framework\Webapi\ServiceInputProcessor->_createFromArray('\Magento\Custom...', Array)

#3 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Webapi\ServiceInputProcessor.php(175): Magento\Framework\Webapi\ServiceInputProcessor->convertValue(Array, '\Magento\Custom...')

#4 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Webapi\ServiceInputProcessor.php(322): Magento\Framework\Webapi\ServiceInputProcessor->_createFromArray('Wilson\Accounta...', Array)

#5 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Webapi\ServiceInputProcessor.php(119): Magento\Framework\Webapi\ServiceInputProcessor->convertValue(Array, 'Wilson\Accounta...')

#6 D:\nginx-1.8.0\websites\magento21\vendor\magento\module-webapi\Controller\Rest\InputParamsResolver.php(101): Magento\Framework\Webapi\ServiceInputProcessor->process('Wilson\Accounta...', 'createProntoAcc...', Array)

#7 D:\nginx-1.8.0\websites\magento21\vendor\magento\module-webapi\Controller\Rest.php(299): Magento\Webapi\Controller\Rest\InputParamsResolver->resolve()

#8 D:\nginx-1.8.0\websites\magento21\vendor\magento\module-webapi\Controller\Rest.php(216): Magento\Webapi\Controller\Rest->processApiRequest()

#9 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Interception\Interceptor.php(74): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))

#10 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Interception\Chain\Chain.php(70): Magento\Webapi\Controller\Rest\Interceptor->___callParent('dispatch', Array)

#11 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Interception\Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\Webapi\...', 'dispatch', Object(Magento\Webapi\Controller\Rest\Interceptor), Array, 'infortis_cgen_m...')

#12 D:\nginx-1.8.0\websites\magento21\app\code\Infortis\Cgen\Plugin\Magento\Framework\App\FrontController.php(32): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))

#13 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Interception\Interceptor.php(142): Infortis\Cgen\Plugin\Magento\Framework\App\FrontController->aroundDispatch(Object(Magento\Webapi\Controller\Rest\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))

#14 D:\nginx-1.8.0\websites\magento21\var\generation\Magento\Webapi\Controller\Rest\Interceptor.php(39): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins('dispatch', Array, Array)

#15 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\App\Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))

#16 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\App\Bootstrap.php(258): Magento\Framework\App\Http->launch()

#17 D:\nginx-1.8.0\websites\magento21\pub\index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))

#18 {main}

@dbsdsun dbsdsun changed the title exception message is wrong in findAccessorMethodName() of Magento\Framework\Reflection\NameFinder exception message is wrong and misleading in findAccessorMethodName() of Magento\Framework\Reflection\NameFinder May 26, 2017
@magento-engcom-team magento-engcom-team added 2.1.x bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 5, 2017
@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Oct 2, 2017
@magento-engcom-team
Copy link
Contributor

@dbsdsun, thank you for your report.
We've created internal ticket(s) MAGETWO-80587 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 11, 2017
@RomaKis RomaKis self-assigned this Nov 15, 2017
@okorshenko
Copy link
Contributor

The issue has been fixed and delivered to 2.2-develop branch

@okorshenko okorshenko added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Nov 16, 2017
@okorshenko
Copy link
Contributor

Hi @dbsdsun. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1323 by @magento-engcom-team in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@okorshenko okorshenko added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Feb 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

5 participants