The profile entity reference field on the user entity is always computing multiple profiles

Created on 18 October 2022, over 1 year ago
Updated 15 May 2024, about 1 month ago

Problem/Motivation

Getting the following error when trying to include profiles via the user resource with JSON:API:
If cardinality is not unlimited, the number of given resources must not exceed the cardinality of the collection.

Steps to reproduce

  • Create multiple profiles via UI or via JSON:API for the associated user.
  • Edit the associated profile type and disable the Allow multiple profiles per user setting.
  • Request the associated user with profiles included via JSON:API:
    GET /jsonapi/user/user/<uuid>?include=<profile_type>_profiles

Proposed resolution

The profile entity reference field on the user entity is always computing multiple profiles. It should consider the cardinality and load a single profile when the associated profile type does not allow multiple profiles per user.

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇳🇱Netherlands bojan_dev

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 jigarius Montréal

    Findings

    I am facing a similar problem but I believe the problem might be bigger so I'll just share my thoughts.

    1. Set up profile type A for role 1
    2. Set up profile type B for role 2
    3. Create a user account with role 1
    4. See the users profiles from the "profiles" page
    5. Observe: There is a profile A which is set as default
    6. Observe: There is a profile B which is set as default

    Thoughts

    1. It seems like all types of profiles are created for all users. If I have 100 users and 4 profile types, I get 400 profiles.
    2. If I create a view to display user info along with their default profile, I get multiple records per user!
    3. Even if the user doesn't have role 2, they still have profile B.

    Would this classify as data corruption or a data-layer-level anomaly? If yes, then I believe this issue should be treated as a major bug.

Production build 0.69.0 2024