Typescript SDK Cloudsave.AdminConcurrentRecordAdminApi failing to parse response

CODE

await Cloudsave.AdminConcurrentRecordAdminApi(this.m_sdk, serverAccessArgs)
                .updateConcurrentRecord_ByUserId_ByKey(
                    userId,
                    KEY,
                    {
                        set_by: setBy,
                        updatedAt: updatedAt,
                        value: { value: newCount }
                    });

ERROR

"Error: response from url \"/cloudsave/v1/admin/namespaces/<ph>/users/f929a150609a45feac678f107ddd0184/concurrent/records/<ph>\" doesn't match model \"PlayerRecordConcurrentUpdateResponse\"\n    at C:\\<ph>\\src\\<ph>\\online-services-monorepo\\node_modules\\@accelbyte\\sdk\\dist\\cjs\\node\\index.cjs:294:23\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async wrapNetworkCallSafely (C:\\<ph>\\src\\<ph>\\online-services-monorepo\\node_modules\\@accelbyte\\sdk\\dist\\cjs\\node\\index.cjs:312:26)\n    at async Object.updateConcurrentRecord_ByUserId_ByKey (C:\\<ph>\\src\\<ph>\\online-services-monorepo\\node_modules\\@accelbyte\\sdk-cloudsave\\dist\\index.cjs:1288:18)\n    at async OnlineServicesManager.inc<ph>Count (C:\\<ph>\\src\\<ph>\\online-services-monorepo\\packages\\<ph>-game-server\\dist\\online-services-manager.js:115:13)\n    at async GameServerConnectionManager.<anonymous> (C:\\<ph>\\src\\<ph>\\online-services-monorepo\\packages\\<ph>-game-server\\dist\\game.js:112:25)"

  errors: [
    {
      code: 'invalid_type',
      expected: 'object',
      received: 'string',
      path: [],
      message: 'Expected object, received string'
    }
  ]

The operation looks to be succeeding as the cloudsave data is getting properly updated, but it looks as if though the SDK can’t parse the response.

Hello @njupshot

We are currently looking at this.

It would be great if we could have a bit more information to troubleshoot this faster. Where are you running this Typescript code? is this related to Extend code or Game Client code?

Hey Ivan, I’m running this from my dedicated game server code written in Typescript running on NodeJS v18.17.1. No Extend involvement here.

Hi @njupshot

As the WebSDK is strongly typed, it appears there’s an issue with an incompatible payload,

Could you let us know which version of Cloudsave you’re currently using? You can find this information by navigating to your domain followed by /cloudsave/version, such as https://demo.accelbyte.io/cloudsave/version.

Additionally, what version of the WebSDK are you on? You can determine this by running the command npm list @accelbyte/sdk-cloudsave in your project directory.

{
 "buildDate": "2024-02-09T03:45:23+00:00",
 "gitHash": "0dd6ff5c635d3abb150c41fd3a2b4208b578c689",
 "name": "justice-cloudsave-service",
 "revisionID": "3.15.0",
 "version": "3.15.0",
 "version-roles-seeding": "0.0.46"
}
@accelbyte/sdk-cloudsave@4.0.0

Hi @njupshot,

Thanks for the report. Based on your report, we have identified a problem with the WebSDK.

The concurrent endpoints can return two different success responses:

  • 204 - No Content
  • 200 - With response body

However, the WebSDK is validating the response body of HTTP code 200 even when it receives 204 - No Content. As a workaround, we recommend that you use the responseBody query parameter and set it to true. This way, you will always receive a response body with the updated_at value, which you can use for the next concurrent update without fetching the record again.

Here is the example:

const result = await Cloudsave.AdminConcurrentRecordAdminApi(sdk)
    .updateConcurrentRecord_ByUserId_ByKey(
        userId,
        KEY,
        {
            set_by: setBy,
            updatedAt: updatedAt,
            value: { value: newCount }
        },
        {
            responseBody: true
        });

Sorry for the inconveniences.

Details

responseBody query param is being used to to tell the service to return non empty response

  • false or without query param: return HTTP response code 204 - No Content
  • true: return HTTP response code 200 with response body:
    • Example:

{ "updated_at": "2023-11-16T00:51:55.797Z" }

1 Like