Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

out-of-band invatation with request~attach embedding json can't be decoded #9

Closed
kukgini opened this issue Dec 16, 2022 · 2 comments · Fixed by #11
Closed

out-of-band invatation with request~attach embedding json can't be decoded #9

kukgini opened this issue Dec 16, 2022 · 2 comments · Fixed by #11

Comments

@kukgini
Copy link
Contributor

kukgini commented Dec 16, 2022

I made out-of-band invitation with credential-offer from AcaPy. but AF.Swift produce error when decode it.

Error occured here: OutOfBandInvitation.swift:(31~45)

 public required init(from decoder: Decoder) throws {
        let values = try decoder.container(keyedBy: CodingKeys.self)
        label = try values.decode(String.self, forKey: .label)
        goalCode = try values.decodeIfPresent(String.self, forKey: .goalCode)
        goal = try values.decodeIfPresent(String.self, forKey: .goal)
        accept = try values.decodeIfPresent([String].self, forKey: .accept)
        handshakeProtocols = try values.decodeIfPresent([HandshakeProtocol].self, forKey: .handshakeProtocols)
        requests = try values.decodeIfPresent([Attachment].self, forKey: .requests) <--- error occured here
        services = try values.decode([OutOfBandDidCommService].self, forKey: .services)
        if services.count == 0 {
            throw AriesFrameworkError.frameworkError("Decoding out-of-band invitation failed: no services found")
        }
        imageUrl = try values.decodeIfPresent(String.self, forKey: .imageUrl)
        try super.init(from: decoder)
}

Error message here:

typeMismatch(Swift.String, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "requests~attach", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "data", intValue: nil), CodingKeys(stringValue: "json", intValue: nil)], debugDescription: "Expected to decode String but found a dictionary instead.", underlyingError: nil))

see the Invitation code in attachments.
out-of-band-invitation.txt

@conanoc
Copy link
Contributor

conanoc commented Dec 16, 2022

It's a bug that Attachment decoding fails when the attachment data contains json field instead of base64 field.

@conanoc
Copy link
Contributor

conanoc commented Dec 16, 2022

This is a known issue and I don't know how to handle general json data in an attachment.

@conanoc conanoc changed the title out-of-band invatation with request~attach can't be decoded out-of-band invatation with request~attach embedding json can't be decoded Dec 16, 2022
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 a pull request may close this issue.

2 participants