Datastores: Attempting to increment non-integer datastore value results in unclear error message

Description:

When attempting to increment a datastore entry using IncrementAsync, but said entry contains a non-nil, non-numerical value (so a double, string, boolean, array, dictionary, …), the request errors with a generic internal error message rather than a specific error message indicating what happened.

Repro:

  1. New file and publish it to a live place with Studio API access / live edit a place with Studio API access.
  2. Add a Script object to ServerScriptService.
  3. Set its contents to:
local ds = game:GetService("DataStoreService"):GetDataStore("_TEST")
ds:SetAsync("SomeKey", {}) -- example of a non-number value
-- ds:SetAsync("SomeKey", false) -- another example
-- ds:SetAsync("SomeKey", "hello world!") -- another example
-- ds:SetAsync("SomeKey", 1.23) -- another example (double, not an integer)
ds:IncrementAsync("SomeKey", 1)
  1. Press Play.
  2. Observe Output.

Observed Behavior:

This error message appears:

502: API Services rejected request with error: ApiClient GamePersistenceApiClient exception:

Url = http://gamepersistence.api.roblox.com/v1/Increment

StatusCode = InternalServerError

StatusDescription = Internal Server Error

None of this describes what actually went wrong to the developer.

Desired Behavior:

A clear concise error message, i.e.:

400: API Services rejected request with error: cannot increment non-numerical value

Or anything along those lines.

5 Likes