Skip to content

[Bug]: Need to switch out BlobContainer for UploadBlobOutput #131

@anna-germ

Description

@anna-germ

Summary

Looks like we no longer receive an extra "blob" key indirection when fetching records, meaning using BlobContainer (instead of the preferred UploadBlobOutput) breaks parsing. It works fine if you replace BlobContainer with UploadBlobOutput, at least in AppBskyLexicon.Actor.ProfileRecord.

Reproduction Steps

Primarily from this code block -- getting the "app.bsky.actor.profile" record and attempting to parse it as an AppBskyLexicon.Actor.ProfileRecord.

let resp = try await ATProtoKit().getRepositoryRecord(
  from: did, 
  collection: AppBskyLexicon.Actor.ProfileRecord.type, 
  recordKey: "self"
)

guard let profileRecord = resp.value?.getRecord(ofType: AppBskyLexicon.Actor.ProfileRecord.self)
else {
  // throw
}

Expected Results

Expected the "app.bsky.actor.profile" record to parse correctly as an AppBskyLexicon.Actor.ProfileRecord type.

Actual Results

When parsing the "app.bsky.actor.profile" record value, the current implementation of AppBskyLexicon.Actor.ProfileRecord throws an error, due to the assumption that the avatar key has a blob key within it, when in fact avatar just maps directly to an UploadBlobOutput.

error loading profile keyNotFound(CodingKeys(stringValue: "blob", intValue: nil), 
Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "value", intValue: nil), 
CodingKeys(stringValue: "avatar", intValue: nil)], debugDescription: "No value associated with key 
CodingKeys(stringValue: \"blob\", intValue: nil) (\"blob\").", underlyingError: nil))

What operating systems did you experience this bug?

iOS/iPadOS

Operating System Version

iOS 18.2

ATProtoKit Version

0.25.3

Additional Context

Within AppBskyLexicon.Actor.ProfileRecord, we just need to update avatarBlob and bannerBlob to have type ComAtprotoLexicon.Repository.UploadBlobOutput? instead of ComAtprotoLexicon.Repository.BlobContainer?.

I can check if BlobContainer can be replaced everywhere or if it's just AppBskyLexicon.Actor.ProfileRecord, once y'all approve this bug to warrant a PR! And it seems this bug is good news, given your note on the BlobContainer struct...

// MARK: -
// TODO: Find a way to remove BlobContainer without breaking the JSON encoding.
// This will be here until a way to remove this without the issues of
// the JSON encoding are solved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions