Skip to content

feat: enhance identifier handling with new generated model#64

Open
Sotatek-DucPhung wants to merge 25 commits intomainfrom
feat/enchange-identifier-handling-with-new-generated-model
Open

feat: enhance identifier handling with new generated model#64
Sotatek-DucPhung wants to merge 25 commits intomainfrom
feat/enchange-identifier-handling-with-new-generated-model

Conversation

@Sotatek-DucPhung
Copy link
Collaborator

  • Introduced IdentifierModelConverter for converting generated KERIA models to domain models.
  • Added IdentifierPayloadMapper to build request payloads for identifier endpoints.
  • Updated Identifier class to utilize GeneratedModelMapper for JSON parsing.
  • Modified IdentifierListResponse to use a list of Identifier objects instead of generic Object.
  • Implemented KeyStateRecordDeserializer to handle deserialization of KeyStateRecord.
  • Centralized Jackson configuration in GeneratedModelConfig for better management of generated models.
  • Updated various tests to reflect changes in identifier handling and ensure consistency.

- Introduced IdentifierModelConverter for converting generated KERIA models to domain models.
- Added IdentifierPayloadMapper to build request payloads for identifier endpoints.
- Updated Identifier class to utilize GeneratedModelMapper for JSON parsing.
- Modified IdentifierListResponse to use a list of Identifier objects instead of generic Object.
- Implemented KeyStateRecordDeserializer to handle deserialization of KeyStateRecord.
- Centralized Jackson configuration in GeneratedModelConfig for better management of generated models.
- Updated various tests to reflect changes in identifier handling and ensure consistency.
ObjectNode node = mapper.readTree(p);

coerceToString(node, "kt");
coerceToString(node, "nt");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really ever get ints back from the API? I thought it was always strings. (I know the API for creating an identifier accepts both though, which is different)

Copy link
Collaborator Author

@Sotatek-DucPhung Sotatek-DucPhung Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We hit a parse failure when kt/nt came back as an array (rotation thresholds), so this coerces non-text (array/number) to a string before binding.
If the API is guaranteed to return strings only, I can tighten this to handle only arrays (or drop the coercion and let it fail loudly). Let me know your prefer

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, but it's an array of strings. I think @Sotatek-Patrick-Vu might be fixing this, or have fixed it. We should return the string array, not a string.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated in coerceToString method

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right but is it possible to receive a numeric response from the API? I don't think it is (may be a mistake in Patrick's generated models)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sotatek-Patrick-Vu could you please take a look for these field ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are expecting kt, nt properties are string or array string or array of array string But It seems we cannot generate correct in java

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sotatek-DucPhung @Sotatek-PhongVu @Sotatek-Patrick-Vu It's also not generated correctly in Signify-TS: https://github.com/WebOfTrust/signify-ts/blob/main/src/types/keria-api-schema.ts#L363

This is referring to the Key State only.

So I think there are missing changes in KERIA to generate this correctly in both Signify-TS and Signify-Java: cardano-foundation/keria#16

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After fixing keria and here is the new type in signify-ts:

KeyStateRecord {
...
    kt: string | string[];
    nt: string | string[];
...
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed @Sotatek-Patrick-Vu if you can fix this PR to remove coerceToString and have proper types that'd be great!

@Sotatek-DucPhung Sotatek-DucPhung force-pushed the feat/enchange-identifier-handling-with-new-generated-model branch from 6666b59 to c099e48 Compare December 3, 2025 11:43
ObjectNode node = mapper.readTree(p);

coerceToString(node, "kt");
coerceToString(node, "nt");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still pending a response here!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointer to https://github.com/cardano-foundation/cf-signify-java/pull/59/files#r2604004041

Should be resolved before this PR is merged!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sotatek-DucPhung Please check my comment there: #59 (comment)

Those changes MUST be fixed in this PR before merging.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it will take time to fix those, and we resolve the other comment in this thread first. We could defer fixing these until the next PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, sounds good to me

@Sotatek-DucPhung
Copy link
Collaborator Author

@iFergal please take a look again! Thanks

return Optional.empty();
}

// Note: KERIA can return either a single object or an array
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is true:

        states = []
        for pre in pres:
            if pre not in agent.hby.kevers:
                continue

            kever = agent.hby.kevers[pre]
            states.append(asdict(kever.state()))

        rep.status = falcon.HTTP_200
        rep.content_type = "application/json"
        rep.data = json.dumps(states).encode("utf-8")

In fact, this endpoint could just take pre and call .list([pre]) or something

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this keria endpoint return an array right ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. For both .get and .list it will return a list from the endpoint. If .get, it will be an array of length 1 at most.

(It could be [] if you call .get with an AID that KERIA does not know about (the continue line above))

return Optional.of(Utils.fromJson(res.body(), Object.class));

String body = res.body();
if (body == null || body.isBlank()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will always at least return an empty array

ObjectNode node = mapper.readTree(p);

coerceToString(node, "kt");
coerceToString(node, "nt");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect, we are not meant to have strings of JSON arrays. We are meant to have arrays.

Please work with Patrick to get the OpenAPI changes needed to update the generated model and have the correct format.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sotatek-DucPhung Please check my comment there: #59 (comment)

Those changes MUST be fixed in this PR before merging.

import static org.cardanofoundation.signify.core.Httping.parseRangeHeaders;

public class Identifier {
public class IdentifierController {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why we need to change this class name?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class name is defined in Signify itself (not a type from KERIA), so I guess it was renamed to not conflict with the generated Identifier.java. But if we update that, we should be updating the others to be consistent.

However, it's not really a HTTP controller. This is the class used in client.identifiers()

@Sotatek-Patrick-Vu
Copy link
Collaborator

Sotatek-Patrick-Vu commented Feb 12, 2026

@iFergal Do you think we need to re-generate models because we changed this in keria? WebOfTrust/keria@262b7ce

@iFergal
Copy link
Collaborator

iFergal commented Feb 12, 2026

@Sotatek-Patrick-Vu imo lets do this:

  • Re-generate the modals using main, and create a PR against main to update those
  • Rebase this PR

That way, this PR just shows the changes as a result of updating the type generation config for the plugin, and not mixed with changes from the new KERIA API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants