TBD54566975 / web5-kt

Apache License 2.0
10 stars 10 forks source link

[Bug] NPE thrown when no verification method id in the DNS packet #333

Closed angiejones closed 1 month ago

angiejones commented 1 month ago

The SDK is unable to resolve a valid DID that does not contain a verification method ID in the DNS packet.

To Reproduce:

    val pfiDid = "did:dht:ozn5c51ruo7z63u1h748ug7rw5p1mq3853ytrd5gatu9a8mm8f1o"
    val resolution = DidDht.resolve(pfiDid)
    println("resolution: $resolution")

returns:

resolution: {"didDocumentMetadata":{},"didResolutionMetadata":{"error":"internalError"}}

Expected behavior:

Successful resolution. Resolving this same DID in tbdex-js works.

from @decentralgabe:

the code does not handle the case where there’s no verification method id in the DNS packet this is a valid response, as the id can be omitted for the identity key (verification method encoded in the DID identifier itself)

Supporting Material

failing here with NPE. in the screenshot, data["id"] is null in DidDht:handleVerificationMethods()

    fromDnsPacket(did, dnsPacket).let { (didDocument, types) ->
      return DidResolutionResult(
        didDocument = didDocument,
        didDocumentMetadata = DidDhtDocumentMetadata(types = types.map { it.index })
      )
    }

image

Additional context Hackathon users are running into this. If possible, can we get a hotfix on SDK version 2.0 that doesn't include the upgrade to protocol 2.0?