(fix) VM resolution strategy correction#3622
(fix) VM resolution strategy correction#3622esune merged 4 commits intoopenwallet-foundation:mainfrom
Conversation
Signed-off-by: George Mulhearn <gmulhearn@anonyome.com>
|
Discovered this while testing W3C VCDM issuance (over DIDComm) with a cheqd DID. |
|
Signed-off-by: George Mulhearn <gmulhearn@anonyome.com>
There was a problem hiding this comment.
Makes sense 👍
I think that the camelCase vs snake_case headaches should be avoided by aliasing the Pydantic fields, but that requires changes in pydid
@dbluhm
e.g.
class DIDDocumentRoot(Resource):
assertion_method: Optional[List[Union[DIDUrl, VerificationMethod]]] = Nonecould be:
class DIDDocumentRoot(Resource):
assertion_method: Optional[List[Union[DIDUrl, VerificationMethod]]] = Field(None, alias="assertionMethod")Looks like Pydantic has a way to generate aliases automatically: https://docs.pydantic.dev/2.1/usage/model_config/#alias-generator
I'll post as an issue on pydid (edit: Indicio-tech/pydid#186)
|
@ff137 are we good with merging this now, or do we want to wait and see if the upstream library fixes the issue first with aliasing field names? |
|
So it seems that camelCase aliases are already implemented for the pydid resources. However, the The way to get aliased fields would be to dump the model to a dictionary: The pydid DIDDocument can deserialize either snake_case or camelCase fields, so that would be the benefit in first converting to a DIDDocument, so that it's standardised. But, if the standard is to use camelCase already, then it's much of a muchness. |
…olve-fix (fix) VM resolution strategy correction
* Merge pull request openwallet-foundation#3622 from anonyome/gm/vm-resolve-fix (fix) VM resolution strategy correction * fix for inline VMs Signed-off-by: George Mulhearn <gmulhearn@anonyome.com> --------- Signed-off-by: George Mulhearn <gmulhearn@anonyome.com> Co-authored-by: Emiliano Suñé <emiliano.sune@gmail.com>



The current VM resolution strategy will get potential VMs by getting the set VMs of that
proof_purpose(e.g. "assertionMethod", "authentication") from thepydidformattedDIDDocument. It does this with agetattr(e.g.getattr(doc, "assertionMethod", []).The problem is that the class attributes of the
DIDDocumentclass are snake case (assertion_method), so attempts to use the proof purposeassertionMethodresult in an empty result when you try to get theassertionMethodattribute.I've just changed this to
.getthe attribute from the original raw doc dict instead, which has the attributes/keys in the camelCase format.The new test is a regression test - it fails before the fix