ittybittyapps / appstoreconnect-cli

An easy to use command-line tool for interacting with the Apple AppStore Connect API
MIT License
172 stars 17 forks source link

Bug: 'users' command can't decode the response with certain "Additional Resources" #259

Open roseyuanzhang opened 1 year ago

roseyuanzhang commented 1 year ago

🌎 Environment

💬 Description

'users' command can't decode the response when the user role has certain "Additional Resources". So far the "Create Apps" and "Access to Cloud Managed Developer ID Certificate" are the two giving me errors.

🦶 Reproduction Steps for "Create Apps" Additional Resources

  1. A user has the "Developer" role, and "Create Apps" as "Additional Resources" in the AppStoreConnect UI.
  2. Run this $ asc users info --api-issuer <issuer-id> --api-key-id <key-id> -v <user-email>

🤔 Expected Results

+--------------------------+------------+-----------+-----------+----------------------+------------------+--------------+
| Username                 | First Name | Last Name | Role      | Provisioning Allowed | All Apps Visible | Visible Apps |
+--------------------------+------------+-----------+-----------+----------------------+------------------+--------------+
| myname@gmail.com | Firstname       | Lastname     | DEVELOPER, CREATE_APPS | No                   | Yes              |              |
+--------------------------+------------+-----------+-----------+----------------------+------------------+--------------+

😲 Actual Results

(Removed the PII from console output)

Error: Failed to decode response:
{
  "data" : [ {
    "type" : "users",
    "id" : "########-####-####-####-############",
    "attributes" : {
      "username" : "myname@gmail.com",
      "firstName" : "Firstname",
      "lastName" : "Lastname",
      "roles" : [ "DEVELOPER", "CREATE_APPS" ],
      "allAppsVisible" : true,
      "provisioningAllowed" : false
    },
    "relationships" : {
      "visibleApps" : {
        "links" : {
          "self" : "https://api.appstoreconnect.apple.com/v1/users/########-####-####-####-############/relationships/visibleApps",
          "related" : "https://api.appstoreconnect.apple.com/v1/users/########-####-####-####-############/visibleApps"
        }
      }
    },
    "links" : {
      "self" : "https://api.appstoreconnect.apple.com/v1/users/########-####-####-####-############"
    }
  } ],
  "links" : {
    "self" : "https://api.appstoreconnect.apple.com/v1/users?filter%5Busername%5D=myname%40gmail.com"
  },
  "meta" : {
    "paging" : {
      "total" : 1,
      "limit" : 50
    }
  }
}
Error: dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "data", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "attributes", intValue: nil), CodingKeys(stringValue: "roles", intValue: nil), _JSONKey(stringValue: "Index 1", intValue: 1)], debugDescription: "Cannot initialize UserRole from invalid String value CREATE_APPS", underlyingError: nil)).

If I removed "Create_Apps" from the AppStoreConnect UI, the same command will give me the correct output:

+--------------------------+------------+-----------+-----------+----------------------+------------------+--------------+
| Username                 | First Name | Last Name | Role      | Provisioning Allowed | All Apps Visible | Visible Apps |
+--------------------------+------------+-----------+-----------+----------------------+------------------+--------------+
| myname@gmail.com | Firstname       | Lastname     | DEVELOPER | No                   | Yes              |              |
+--------------------------+------------+-----------+-----------+----------------------+------------------+--------------+

🦶 Reproduction Steps for "Access to Cloud Managed Developer ID Certificate" Additional Resources

  1. A user has the "Admin" role, and all the choices are checked under "Additional Resources" in the AppStoreConnect UI. I'm not sure how it gets checked for "Access to Cloud Managed Developer ID Certificate" in the first place, as if I remove the "Admin" role and then add the "Admin" role back, I can't manually check the "Access to Cloud Managed Developer ID Certificate" from the AppStoreConnect UI (it grayed out).
  2. Run this $ asc users info --api-issuer <issuer-id> --api-key-id <key-id> -v <user-email>

🤔 Expected Results

+--------------------------+------------+-----------+-----------+----------------------+------------------+--------------+
| Username                 | First Name | Last Name | Role      | Provisioning Allowed | All Apps Visible | Visible Apps |
+--------------------------+------------+-----------+-----------+----------------------+------------------+--------------+
| myname@gmail.com   | Firstname       | Lastname     | ADMIN,CLOUD_MANAGED_DEVELOPER_ID | No                   | Yes              |              |
+--------------------------+------------+-----------+-----------+----------------------+------------------+--------------+

😲 Actual Results

(Removed the PII from console output)

Error: Failed to decode response:
{
  "data" : [ {
    "type" : "users",
    "id" : "########-####-####-####-############",
    "attributes" : {
      "username" : "email@domain.com",
      "firstName" : "Firstname",
      "lastName" : "Lastname",
      "roles" : [ "ADMIN", "CLOUD_MANAGED_DEVELOPER_ID" ],
      "allAppsVisible" : true,
      "provisioningAllowed" : true
    },
    "relationships" : {
      "visibleApps" : {
        "links" : {
          "self" : "https://api.appstoreconnect.apple.com/v1/users/########-####-####-####-############/relationships/visibleApps",
          "related" : "https://api.appstoreconnect.apple.com/v1/users/########-####-####-####-############/visibleApps"
        }
      }
    },
    "links" : {
      "self" : "https://api.appstoreconnect.apple.com/v1/users/########-####-####-####-############"
    }
  } ],
  "links" : {
    "self" : "https://api.appstoreconnect.apple.com/v1/users?filter%5Busername%5D=email%40domain.com"
  },
  "meta" : {
    "paging" : {
      "total" : 1,
      "limit" : 50
    }
  }
}
Error: dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "data", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "attributes", intValue: nil), CodingKeys(stringValue: "roles", intValue: nil), _JSONKey(stringValue: "Index 1", intValue: 1)], debugDescription: "Cannot initialize UserRole from invalid String value CLOUD_MANAGED_DEVELOPER_ID", underlyingError: nil)).