I'm getting the error
"hydra:description": "Unable to get a property on a non-object.",
when trying to implement a custom operation. I'm trying to figure out what causes this problem and while I've found a dozen or so wild guesses on both stackoverflow and elsewhere, none of the solutions posted there work for me.
I'm trying to figure out how to debug this problem. The trace and info included with the error message is less than helpful:
{
"@context": "/api/contexts/Error",
"@type": "hydra:Error",
"hydra:title": "An error occurred",
"hydra:description": "Unable to get a property on a non-object.",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "/Users/tom/Code/api-platform/vendor/symfony/expression-language/Node/GetAttrNode.php",
"line": 73,
"args": []
},
{
"namespace": "Symfony\\Component\\ExpressionLanguage\\Node",
"short_class": "GetAttrNode",
"class": "Symfony\\Component\\ExpressionLanguage\\Node\\GetAttrNode",
"type": "->",
"function": "evaluate",
"file": "/Users/tom/Code/api-platform/vendor/symfony/expression-language/Node/GetAttrNode.php",
"line": 71,
"args": [
[
"array",
{
"constant": [
"array",
{
"compiler": [
"object",
"Closure"
],
"evaluator": [
"object",
"Closure"
]
}
],
"is_granted": [
"array",
{
"compiler": [
"object",
"Closure"
],
"evaluator": [
"object",
"Closure"
]
}
all of which tells me absolutely nothing about which property on which object it is looking for, what data it is inspecting, and where I should be looking for the problem.
I've tried adding var_dump() statements into both my own code and places like before line 73 in GetAttrNode.php and it doesn't help. It appears that the code does not even hit my controller. I'm fairly certain that the problem isn't in my controller, as at this point the controller is nothing but the stub as described in the documentation (https://api-platform.com/docs/core/operations#creating-custom-operations-and-controllers).
How can I debug this issue and figure out where the problem is?