Identity/get returns incorrect ID (returns member's ID instead of group/identity ID)

Issue Description

There is an ID mismatch issue when calling the Identity/get API to retrieve information for a group or specific identity.

Expected Behavior

The API should return the correct profile data of Group D, including the actual id of Group D.

Actual Behavior

The API returns the profile data belonging to Group D (all other fields are correct), BUT the id field in the response incorrectly contains the ID of User B instead of Group D.

Reproduction Steps

I have a user User B who belongs to group Group D (or has an identity associated with it).

I invoke the API Identity/get targeting the ID/information of Group D.

Stalwart Version

v0.16.x

Installation Method

Binary (Linux)

Database Backend

RocksDB

Blob Storage

RocksDB

Search Engine

Internal

Directory Backend

Internal

I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.

on

I have searched this support forum (open and closed topics) and confirm this is not a duplicate.

on

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

Let me look into the Identity/get implementation to understand this ID mapping behavior.

This is very helpful. Now I can see the root cause clearly. Let me look at the identity creation logic once more to confirm the ID assignment issue.

Want to get info Identity for user D, but received id=B.

Screenshot:

Identities have their own ids, they are independent to account ids.

Even if that’s the case, according to the results in the attached screenshot, the API is returning the exact same id (= b) for two completely different Identities. This makes it impossible to distinguish between them.

Those are identities for different accounts so they can have the same id.