Sleitnick / rbxcloud

CLI and library for Roblox Open Cloud API
https://sleitnick.github.io/rbxcloud/
MIT License
95 stars 10 forks source link

Wrap AssetGetOperation fields done and response in Option #32

Closed kennethloeffler closed 9 months ago

kennethloeffler commented 1 year ago

The done and response fields are sometimes absent from asset get operations for recently created assets, resulting in errors like this:

ReqwestError(
    reqwest::Error {
        kind: Decode,
        source: Error("missing field `done`", line: 1, column: 61),
    },
)

When this happens, it usually takes a few seconds before these fields are present in responses. Here's some output from me retrying this endpoint (now using optional done and response) directly after creating an asset:

[2023-04-18 17:08:28] AssetGetOperation {
[2023-04-18 17:08:28]     path: "operations/43db82d3-ee5e-4df9-986b-dc833ac3d3c1",
[2023-04-18 17:08:28]     done: None,
[2023-04-18 17:08:28]     response: None,
[2023-04-18 17:08:28] }
[2023-04-18 17:08:29] AssetGetOperation {
[2023-04-18 17:08:29]     path: "operations/43db82d3-ee5e-4df9-986b-dc833ac3d3c1",
[2023-04-18 17:08:29]     done: None,
[2023-04-18 17:08:29]     response: None,
[2023-04-18 17:08:29] }
[2023-04-18 17:08:30] AssetGetOperation {
[2023-04-18 17:08:30]     path: "operations/43db82d3-ee5e-4df9-986b-dc833ac3d3c1",
[2023-04-18 17:08:30]     done: None,
[2023-04-18 17:08:30]     response: None,
[2023-04-18 17:08:30] }
[2023-04-18 17:08:31] AssetGetOperation {
[2023-04-18 17:08:31]     path: "operations/43db82d3-ee5e-4df9-986b-dc833ac3d3c1",
[2023-04-18 17:08:31]     done: None,
[2023-04-18 17:08:31]     response: None,
[2023-04-18 17:08:31] }
[2023-04-18 17:08:33] AssetGetOperation {
[2023-04-18 17:08:33]     path: "operations/43db82d3-ee5e-4df9-986b-dc833ac3d3c1",
[2023-04-18 17:08:33]     done: Some(
[2023-04-18 17:08:33]         true,
[2023-04-18 17:08:33]     ),
[2023-04-18 17:08:33]     response: Some(
[2023-04-18 17:08:33]         AssetGetOperationResponse {
[2023-04-18 17:08:33]             response_type: "type.googleapis.com/roblox.open_cloud.assets.v1.Asset",
[2023-04-18 17:08:33]             path: "assets/13176690446",
[2023-04-18 17:08:33]             revision_id: "1",
[2023-04-18 17:08:33]             revision_create_time: "2023-04-19T00:08:31.745079700Z",
[2023-04-18 17:08:33]             asset_id: "13176690446",
[2023-04-18 17:08:33]             display_name: "model",
[2023-04-18 17:08:33]             description: "",
[2023-04-18 17:08:33]             asset_type: "ASSET_TYPE_MODEL",
[2023-04-18 17:08:33]             creation_context: AssetCreationContext {
[2023-04-18 17:08:33]                 creator: User(
[2023-04-18 17:08:33]                     AssetUserCreator {
[2023-04-18 17:08:33]                         user_id: "5701242",
[2023-04-18 17:08:33]                     },
[2023-04-18 17:08:33]                 ),
[2023-04-18 17:08:33]                 expected_price: None,
[2023-04-18 17:08:33]             },
[2023-04-18 17:08:33]         },
[2023-04-18 17:08:33]     ),
[2023-04-18 17:08:33] }

I've only observed this behavior for fbx models. I don't know if it can occur with audio or images, and I'm not sure if it's a bug in the API, but I think rbxcloud should avoid just falling over here!

Mistrustfully commented 11 months ago

It also seems like @type / response_type should be optional as well. When doing a GET operation for a decal asset it seems to be missing. This is the struct I get back:

AssetGetOperation { 
    path: "operations/XXXX", 
    done: Some(true), 
    response: Some(AssetGetOperationResponse { 
        response_type: None, 
        path: "assets/15089823975", 
        revision_id: "1", 
        revision_create_time: "2023-10-16T18:43:17.533253800Z", 
        asset_id: "15089823975", 
        display_name: "hi guys", 
        description: "Uploaded by Tarmac.", 
        asset_type: "Decal", 
        creation_context: AssetCreationContext { 
            creator: User(AssetUserCreator { 
                user_id: "1091164489" 
            }), 
            expected_price: None 
        }
    }) 
}