Skip to content

LinksHandlerTrait : The class "App\Entity\EntityName" cannot be retrieved from "App\Entity\EntityName" #6059

Description

@xterr

API Platform version(s) affected: 3.2.7

Description
RuntimeException is thrown on line 87 in LinksHandlerTrait for:

  1. Entity with a column of type enum
  2. Int BackedEnum, with a member with value = 0
  • The issue is present only when there is a value equal to 0 in the database.
  • The issue happens for single items and collections.
  • For non-enum fields value=0 is accepted and all functionality is as expected.

How to reproduce

enum StateEnum: int {
  case NEW      = 0;
  case ACTIVE   = 1;
  case INACTIVE = 2;
}

#[ORM\Entity]
#[ApiResource]
class Entity {
  #[ORM\Column(type: Types::SMALLINT, enumType: StateEnum::class)]
  #[Groups(['entity:read', 'entity:write'])]
  #[Assert\Choice(callback: [StateEnum::class, 'cases'])]
  state: StateEnum
}

Additional context
After some debugging, I observed that the data was correctly retrieved from the database.
The problem might start from ApiPlatform\GraphQl\State\Provider\ReadProvider#107
ReadProvider

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions