The target_type property is incorrectly of type DataReferenceTargetDefinition

Created on 18 July 2019, over 5 years ago
Updated 9 August 2024, 4 months ago

Problem/Motivation

We've noticed this bug because of #3068744: Not possible to filter by properties for items with multiple DataReferenceTargetDefinition properties β€” necessary for using filtering with Dynamic Entity Reference and Entity Reference Revisions β†’ , which made us thinking if the target_type property should be of the type DataReferenceTargetDefinition and we think that it should not. The reason is that DataReferenceTargetDefinition stands for specific target, but an entity type simply is not a target. The bundle of an entity type might be a bundle, or a specific entity might be a target, but not the entity type itself. Therefore the property should be simply DataDefinition.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Postponed: needs info

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany hchonov πŸ‡ͺπŸ‡ΊπŸ‡©πŸ‡ͺπŸ‡§πŸ‡¬

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡¦Canada jibran Toronto, Canada

    PPMNMI as per the last comment.

  • πŸ‡ΊπŸ‡ΈUnited States ebeyrent

    I have a custom entity with a DER field that allows either users or nodes to be referenced. Here's an example jsonapi representation of that field:

    "subject_entity": {
      "data": {
        "type": "user--user",
        "id": "02873322-eb7c-4984-bf32-7cb7e8ec1b68",
        "meta": {
          "target_type": "user",
          "drupal_internal__target_id": 1237
        }
      },
      "links": {
        "self": {
          "href": "https://my-site.com/jsonapi/my_entity/my_entity/cfbb318c-dc03-4061-b0a2-b123ac904a5c/relationships/subject_entity?resourceVersion=id%3A387"
        }
      }
    }
    

    Because this field can reference either users or nodes, I want to be able to filter by the target_type:

    jsonapi/my_entity/my_entity?filter[subject_entity.meta.drupal_internal__target_id]=1237&filter[subject_entity.meta.target_type]=user
    

    This fails:

    "errors": [
      {
        "title": "Bad Request",
        "status": "400",
        "detail": "Invalid nested filtering. The field `target_type`, given in the path `subject_entity.meta.target_type`, does not exist.",
    

    Worse, if I try to include that object in my query like this:

    /jsonapi/my_entity/my_entity?include=subject_entity
    

    I get this error:

    "errors": [
            {
                "title": "Bad Request",
                "status": "400",
                "detail": "`subject_entity` is not a valid relationship field name. Possible values: revision_user, subject_entity, related_entity.",
    
  • πŸ‡ΊπŸ‡ΈUnited States ebeyrent

    I've applied the patch, and it fixes the issue of not being able to filter by target_type. It does not fix the inability to include the referenced data.

Production build 0.71.5 2024