Unexpected non-iterable value for to-many relation bug introduced in v2.5.2 or v2.5.3 #5162
Unanswered
tristanbes
asked this question in
Q&A
Replies: 3 comments
-
|
Please check #3278 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
@tristanbes The problem is here: "sectors": null
|
Beta Was this translation helpful? Give feedback.
0 replies
-
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
API Platform version(s) affected: in version v2.5.2 or v2.5.3 (coulnd't test 2.5.2 as it generated error 500 for the given request)
Description
When I try to get a collection of users, in v2.5.1, it's working well
Response:
{ "@context": "/api/contexts/User", "@id": "/api/users", "@type": "hydra:Collection", "hydra:member": [ { "@id": "/api/users/1", "@type": "User", "id": 1, "email": "[email protected]", "roles": [ "ROLE_TECHPRO_ADMIN", "ROLE_USER" ], "civility": "CIVILITY_MISTER", "firstName": "Lily", "lastName": "Dibbert", "mobile": "+33600000000", "phone": "+33400000000", "profession": "PROFESSION_DIRECTOR", "info": "Un texte d'info plutot court.", "avatar": { "@id": "/api/media/1", "@type": "http://schema.org/MediaObject", "title": "avatar 1", "filename": "sample_pic.jpeg", "mimeType": "image/png", "size": 76134831, "contentUrl": "http://cosmos.vm/media/cache/resolve/original/fixtures/sample_pic.jpeg" }, "addressIsSameAsSociety": true, "address": { "@id": "/api/addresses/1", "id": 1, "street": "30 Rue Sergent Michel Berthet", "additional": null, "postalCode": "69009", "town": "Lyon", "country": "France" }, "events": [], "createdAt": "2019-03-01T14:00:00+01:00", "updatedAt": "2019-04-01T15:55:00+02:00", "primaryRole": "ROLE_TECHPRO_OFFICES", "sectors": null }, .......How to reproduce
Upgrade to v2.5.3 (the v2.5.2 gave me error 500 when running this request)
Response:
Unexpected non-iterable value for to-many relation
{ "@context": "/api/contexts/Error", "@type": "hydra:Error", "hydra:title": "An error occurred", "hydra:description": "Unexpected non-iterable value for to-many relation.", "trace": [ { "namespace": "", "short_class": "", "class": "", "type": "", "function": "", "file": "/srv/app/vendor/api-platform/core/src/Serializer/AbstractItemNormalizer.php", "line": 526, "args": [] }, { "namespace": "ApiPlatform\\Core\\Serializer", "short_class": "AbstractItemNormalizer", "class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer", "type": "->", "function": "getAttributeValue", "file": "/srv/app/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php", "line": 183, "args": [ [ "object", "App\\Entity\\User\\User" ], [ "string", "sectors" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "read" ], [ "string", "user" ], [ "string", "address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "get" ], "resource_class": [ "string", "App\\Entity\\User\\User" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/api/users" ], "uri": [ "string", "http://cosmos.vm/api/users" ], "resources": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "exclude_from_cache_key": [ "array", [ [ "string", "resources" ], [ "string", "resources_to_push" ] ] ], "resources_to_push": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "api_sub_level": [ "boolean", true ], "jsonld_has_context": [ "boolean", true ], "iri": [ "string", "/api/users/1" ], "api_normalize": [ "boolean", true ], "cache_key": [ "string", "0048d7cbc86087b8ea231aa42a2ffe2f" ], "circular_reference_limit_counters": [ "array", { "000000003a548a7d0000000071563da7": [ "integer", 1 ] } ], "api_attribute": [ "string", "sectors" ] } ] ] }, { "namespace": "Symfony\\Component\\Serializer\\Normalizer", "short_class": "AbstractObjectNormalizer", "class": "Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer", "type": "->", "function": "normalize", "file": "/srv/app/vendor/api-platform/core/src/Serializer/AbstractItemNormalizer.php", "line": 151, "args": [ [ "object", "App\\Entity\\User\\User" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "read" ], [ "string", "user" ], [ "string", "address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "get" ], "resource_class": [ "string", "App\\Entity\\User\\User" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/api/users" ], "uri": [ "string", "http://cosmos.vm/api/users" ], "resources": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "exclude_from_cache_key": [ "array", [ [ "string", "resources" ], [ "string", "resources_to_push" ] ] ], "resources_to_push": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "api_sub_level": [ "boolean", true ], "jsonld_has_context": [ "boolean", true ], "iri": [ "string", "/api/users/1" ], "api_normalize": [ "boolean", true ], "cache_key": [ "string", "0048d7cbc86087b8ea231aa42a2ffe2f" ], "circular_reference_limit_counters": [ "array", { "000000003a548a7d0000000071563da7": [ "integer", 1 ] } ] } ] ] }, { "namespace": "ApiPlatform\\Core\\Serializer", "short_class": "AbstractItemNormalizer", "class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer", "type": "->", "function": "normalize", "file": "/srv/app/vendor/api-platform/core/src/JsonLd/Serializer/ItemNormalizer.php", "line": 80, "args": [ [ "object", "App\\Entity\\User\\User" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "read" ], [ "string", "user" ], [ "string", "address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "get" ], "resource_class": [ "string", "App\\Entity\\User\\User" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/api/users" ], "uri": [ "string", "http://cosmos.vm/api/users" ], "resources": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "exclude_from_cache_key": [ "array", [ [ "string", "resources" ], [ "string", "resources_to_push" ] ] ], "resources_to_push": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "api_sub_level": [ "boolean", true ], "jsonld_has_context": [ "boolean", true ], "iri": [ "string", "/api/users/1" ], "api_normalize": [ "boolean", true ] } ] ] }, { "namespace": "ApiPlatform\\Core\\JsonLd\\Serializer", "short_class": "ItemNormalizer", "class": "ApiPlatform\\Core\\JsonLd\\Serializer\\ItemNormalizer", "type": "->", "function": "normalize", "file": "/srv/app/vendor/symfony/serializer/Serializer.php", "line": 152, "args": [ [ "object", "App\\Entity\\User\\User" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "read" ], [ "string", "user" ], [ "string", "address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "get" ], "resource_class": [ "string", "App\\Entity\\User\\User" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/api/users" ], "uri": [ "string", "http://cosmos.vm/api/users" ], "resources": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "exclude_from_cache_key": [ "array", [ [ "string", "resources" ], [ "string", "resources_to_push" ] ] ], "resources_to_push": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "api_sub_level": [ "boolean", true ], "jsonld_has_context": [ "boolean", true ], "iri": [ "string", "/api/users/1" ], "api_normalize": [ "boolean", true ] } ] ] }, { "namespace": "Symfony\\Component\\Serializer", "short_class": "Serializer", "class": "Symfony\\Component\\Serializer\\Serializer", "type": "->", "function": "normalize", "file": "/srv/app/vendor/api-platform/core/src/Hydra/Serializer/CollectionNormalizer.php", "line": 87, "args": [ [ "object", "App\\Entity\\User\\User" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "read" ], [ "string", "user" ], [ "string", "address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "get" ], "resource_class": [ "string", "App\\Entity\\User\\User" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/api/users" ], "uri": [ "string", "http://cosmos.vm/api/users" ], "resources": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "exclude_from_cache_key": [ "array", [ [ "string", "resources" ], [ "string", "resources_to_push" ] ] ], "resources_to_push": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "api_sub_level": [ "boolean", true ], "jsonld_has_context": [ "boolean", true ] } ] ] }, { "namespace": "ApiPlatform\\Core\\Hydra\\Serializer", "short_class": "CollectionNormalizer", "class": "ApiPlatform\\Core\\Hydra\\Serializer\\CollectionNormalizer", "type": "->", "function": "normalize", "file": "/srv/app/vendor/api-platform/core/src/Hydra/Serializer/PartialCollectionViewNormalizer.php", "line": 55, "args": [ [ "object", "ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Paginator" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "read" ], [ "string", "user" ], [ "string", "address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "get" ], "resource_class": [ "string", "App\\Entity\\User\\User" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/api/users" ], "uri": [ "string", "http://cosmos.vm/api/users" ], "resources": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "exclude_from_cache_key": [ "array", [ [ "string", "resources" ], [ "string", "resources_to_push" ] ] ], "resources_to_push": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "api_sub_level": [ "boolean", true ], "jsonld_has_context": [ "boolean", true ] } ] ] }, { "namespace": "ApiPlatform\\Core\\Hydra\\Serializer", "short_class": "PartialCollectionViewNormalizer", "class": "ApiPlatform\\Core\\Hydra\\Serializer\\PartialCollectionViewNormalizer", "type": "->", "function": "normalize", "file": "/srv/app/vendor/api-platform/core/src/Hydra/Serializer/CollectionFiltersNormalizer.php", "line": 73, "args": [ [ "object", "ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Paginator" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "read" ], [ "string", "user" ], [ "string", "address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "get" ], "resource_class": [ "string", "App\\Entity\\User\\User" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/api/users" ], "uri": [ "string", "http://cosmos.vm/api/users" ], "resources": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "exclude_from_cache_key": [ "array", [ [ "string", "resources" ], [ "string", "resources_to_push" ] ] ], "resources_to_push": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ] } ] ] }, { "namespace": "ApiPlatform\\Core\\Hydra\\Serializer", "short_class": "CollectionFiltersNormalizer", "class": "ApiPlatform\\Core\\Hydra\\Serializer\\CollectionFiltersNormalizer", "type": "->", "function": "normalize", "file": "/srv/app/vendor/symfony/serializer/Serializer.php", "line": 152, "args": [ [ "object", "ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Paginator" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "read" ], [ "string", "user" ], [ "string", "address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "get" ], "resource_class": [ "string", "App\\Entity\\User\\User" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/api/users" ], "uri": [ "string", "http://cosmos.vm/api/users" ], "resources": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "exclude_from_cache_key": [ "array", [ [ "string", "resources" ], [ "string", "resources_to_push" ] ] ], "resources_to_push": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ] } ] ] }, { "namespace": "Symfony\\Component\\Serializer", "short_class": "Serializer", "class": "Symfony\\Component\\Serializer\\Serializer", "type": "->", "function": "normalize", "file": "/srv/app/vendor/symfony/serializer/Serializer.php", "line": 125, "args": [ [ "object", "ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Paginator" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "read" ], [ "string", "user" ], [ "string", "address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "get" ], "resource_class": [ "string", "App\\Entity\\User\\User" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/api/users" ], "uri": [ "string", "http://cosmos.vm/api/users" ], "resources": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "exclude_from_cache_key": [ "array", [ [ "string", "resources" ], [ "string", "resources_to_push" ] ] ], "resources_to_push": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ] } ] ] }, { "namespace": "Symfony\\Component\\Serializer", "short_class": "Serializer", "class": "Symfony\\Component\\Serializer\\Serializer", "type": "->", "function": "serialize", "file": "/srv/app/vendor/api-platform/core/src/EventListener/SerializeListener.php", "line": 95, "args": [ [ "object", "ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Paginator" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "read" ], [ "string", "user" ], [ "string", "address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "get" ], "resource_class": [ "string", "App\\Entity\\User\\User" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/api/users" ], "uri": [ "string", "http://cosmos.vm/api/users" ], "resources": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ], "exclude_from_cache_key": [ "array", [ [ "string", "resources" ], [ "string", "resources_to_push" ] ] ], "resources_to_push": [ "object", "ApiPlatform\\Core\\Serializer\\ResourceList" ] } ] ] }, { "namespace": "ApiPlatform\\Core\\EventListener", "short_class": "SerializeListener", "class": "ApiPlatform\\Core\\EventListener\\SerializeListener", "type": "->", "function": "onKernelView", "file": "/srv/app/vendor/symfony/event-dispatcher/Debug/WrappedListener.php", "line": 126, "args": [ [ "object", "Symfony\\Component\\HttpKernel\\Event\\ViewEvent" ], [ "string", "kernel.view" ], [ "object", "Symfony\\Component\\HttpKernel\\Debug\\TraceableEventDispatcher" ] ] }, { "namespace": "Symfony\\Component\\EventDispatcher\\Debug", "short_class": "WrappedListener", "class": "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener", "type": "->", "function": "__invoke", "file": "/srv/app/vendor/symfony/event-dispatcher/EventDispatcher.php", "line": 264, "args": [ [ "object", "Symfony\\Component\\HttpKernel\\Event\\ViewEvent" ], [ "string", "kernel.view" ], [ "object", "Symfony\\Component\\HttpKernel\\Debug\\TraceableEventDispatcher" ] ] }, { "namespace": "Symfony\\Component\\EventDispatcher", "short_class": "EventDispatcher", "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher", "type": "->", "function": "doDispatch", "file": "/srv/app/vendor/symfony/event-dispatcher/EventDispatcher.php", "line": 239, "args": [ [ "array", [ [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ] ] ], [ "string", "kernel.view" ], [ "object", "Symfony\\Component\\HttpKernel\\Event\\ViewEvent" ] ] }, { "namespace": "Symfony\\Component\\EventDispatcher", "short_class": "EventDispatcher", "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher", "type": "->", "function": "callListeners", "file": "/srv/app/vendor/symfony/event-dispatcher/EventDispatcher.php", "line": 73, "args": [ [ "array", [ [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ] ] ], [ "string", "kernel.view" ], [ "object", "Symfony\\Component\\HttpKernel\\Event\\ViewEvent" ] ] }, { "namespace": "Symfony\\Component\\EventDispatcher", "short_class": "EventDispatcher", "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher", "type": "->", "function": "dispatch", "file": "/srv/app/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php", "line": 168, "args": [ [ "object", "Symfony\\Component\\HttpKernel\\Event\\ViewEvent" ], [ "string", "kernel.view" ] ] }, { "namespace": "Symfony\\Component\\EventDispatcher\\Debug", "short_class": "TraceableEventDispatcher", "class": "Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher", "type": "->", "function": "dispatch", "file": "/srv/app/vendor/symfony/http-kernel/HttpKernel.php", "line": 151, "args": [ [ "object", "Symfony\\Component\\HttpKernel\\Event\\ViewEvent" ], [ "string", "kernel.view" ] ] }, { "namespace": "Symfony\\Component\\HttpKernel", "short_class": "HttpKernel", "class": "Symfony\\Component\\HttpKernel\\HttpKernel", "type": "->", "function": "handleRaw", "file": "/srv/app/vendor/symfony/http-kernel/HttpKernel.php", "line": 68, "args": [ [ "object", "Symfony\\Component\\HttpFoundation\\Request" ], [ "integer", 1 ] ] }, { "namespace": "Symfony\\Component\\HttpKernel", "short_class": "HttpKernel", "class": "Symfony\\Component\\HttpKernel\\HttpKernel", "type": "->", "function": "handle", "file": "/srv/app/vendor/symfony/http-kernel/Kernel.php", "line": 201, "args": [ [ "object", "Symfony\\Component\\HttpFoundation\\Request" ], [ "integer", 1 ], [ "boolean", true ] ] }, { "namespace": "Symfony\\Component\\HttpKernel", "short_class": "Kernel", "class": "Symfony\\Component\\HttpKernel\\Kernel", "type": "->", "function": "handle", "file": "/srv/app/public/index.php", "line": 25, "args": [ [ "object", "Symfony\\Component\\HttpFoundation\\Request" ] ] } ] }Additional Context
As I understand from the trace, ApiPlatform tries to call
getSectors()from theUser::class. This is a problem, because this method only exists insideTechproCommercial::classandTechproAgent:class.I checked that no reference of
sectorsinside theUser::classis found, so I don't understand why this is happening.Our user class has 2 inherited sub Users
Beta Was this translation helpful? Give feedback.
All reactions