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

CiGitUser Decoding Fails for Empty avatarUrl String. #297

Open
psbss opened this issue Jan 19, 2025 · 1 comment
Open

CiGitUser Decoding Fails for Empty avatarUrl String. #297

psbss opened this issue Jan 19, 2025 · 1 comment

Comments

@psbss
Copy link

psbss commented Jan 19, 2025

Hi, I have an question.

Summary

The CiGitUser struct in the SDK fails to decode when the avatarUrl field in the API response is an empty string (""). This results in a dataCorrupted decoding error due to the avatarUrl being defined as a URL? type, which cannot handle invalid or empty URL strings.


Steps to Reproduce

  1. make CiBuildRun request

     func postCiBuildRuns(gitReferenceId: String, workflowId: String) async throws -> CiBuildRunResponse {
         let request = CiBuildRunCreateRequest(
             data: .init(
                 type: .ciBuildRuns,
                 relationships: .init(
                     workflow: .init(
                         data: .init(
                             type: .ciWorkflows,
                             id: workflowId
                         )
                     ),
                     sourceBranchOrTag: .init(
                         data: .init(
                             type: .scmGitReferences,
                             id: gitReferenceId
                         )
                     )
                 )
             )
         )
         let response = try await sendRequest(APIEndpoint.v1.ciBuildRuns.post(request))
         return response
     }
  2. Attempt to decode the response using the CiGitUser struct.

  3. Observe the following decoding error:

    Error: dataCorrupted(Swift.DecodingError.Context(
      codingPath: [StringCodingKey(stringValue: "avatarUrl", intValue: nil)],
      debugDescription: "Invalid URL string.",
      underlyingError: nil
    ))
    

API Response

Detail
{
  "data" : {
    "type" : "ciBuildRuns",
    "id" : "UUID<Masked>",
    "attributes" : {
      "number" : 27802,
      "createdDate" : "2025-01-19T02:33:23.957Z",
      "startedDate" : null,
      "finishedDate" : null,
      "sourceCommit" : {
        "commitSha" : "",
        "message" : "",
        "author" : {
          "displayName" : "",
          "avatarUrl" : ""
        },
        "committer" : {
          "displayName" : "",
          "avatarUrl" : ""
        },
        "webUrl" : ""
      },
      "destinationCommit" : null,
      "isPullRequestBuild" : false,
      "issueCounts" : null,
      "executionProgress" : "PENDING",
      "completionStatus" : null,
      "startReason" : "MANUAL",
      "cancelReason" : null
    },
    "relationships" : {
      "builds" : {
        "links" : {
          "self" : "https://api.appstoreconnect.apple.com/v1/ciBuildRuns/UUID<Masked>/relationships/builds",
          "related" : "https://api.appstoreconnect.apple.com/v1/ciBuildRuns/UUID<Masked>/builds"
        }
      },
      "actions" : {
        "links" : {
          "self" : "https://api.appstoreconnect.apple.com/v1/ciBuildRuns/UUID<Masked>/relationships/actions",
          "related" : "https://api.appstoreconnect.apple.com/v1/ciBuildRuns/UUID<Masked>/actions"
        }
      }
    },
    "links" : {
      "self" : "https://api.appstoreconnect.apple.com/v1/ciBuildRuns/UUID<Masked>"
    }
  },
  "links" : {
    "self" : "https://api.appstoreconnect.apple.com/v1/ciBuildRuns"
  }
}

Root Cause

The avatarUrl property is defined as URL? in the CiGitUser struct. However, empty strings are not valid URL values and cannot be converted to URL during decoding, causing a dataCorrupted error.


Environment

  • SDK version: 3.6.0
  • Swift version: 5.10
  • Xcode 16.2.0
@psbss
Copy link
Author

psbss commented Jan 29, 2025

Does anyone have same problem?

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

No branches or pull requests

1 participant