GetProductInfo() should still return Description even when field empty

In my opinion, MarketplaceService:GetProductInfo() should still return the Description of an item as just an empty string ("") instead of being nil

local BoostData = MarketplaceService:GetProductInfo(boost.Id, Enum.InfoType.Product)

print(BoostData.Description) -- prints nil

It would be an improvement as it wouldn’t error.

10 Likes

Did you miss the second half of your post? You haven’t explained at all how this would be an improvement.

oh sorry, the deed has been done

It doesn’t error – it returns nil. Are you trying to say you can’t easily concatenate it into a string since you need to do a check first and replace it with an empty string yourself before you can actually use it inside other strings / string properties?

If I do Label.Text = BoostData.Description, it errors

If a description is empty, you would be able to tell and work with it in code in a way that makes sense i.e

if BoostData.Description then
Label.Text = BoostData.Description
else
Label.Text = “No Description Available.”
end

Making this change would break a significant amount of experiences for this reason as well.

Written on phone sorry if any errors

5 Likes

Support.

I had some code for products (which I have yet to assign descriptions to), and I was confused as to why I kept getting errors with it stating it was nil, when I made sure that it got a result back. I noticed it didn’t appear when printing it myself, so I assumed that maybe Description wasn’t passed for products. I changed the description and behold, the description appeared.

If the call returns successfully, I’d expect for all basic values to exist, and if no description is assigned to it, it’ll still be the same type (just an empty string, "").

I believe that it’d be better if it was changed to reduce inconsistencies & friction when coding, especially with unfamiliar APIs, as I expect the type for a description to be consistent. It wouldn’t make sense if string.sub would return nil if the provided string was empty.


@Pavalineox
The workaround for the few games (I’m assuming) which rely on this behavior may be as simple as this:

local Description = ProdInfo.Description
Label.Text = Description == "" and "No Description Available" or Description
2 Likes

If there is no description, the description should be nil. An empty string does not make sense here. All of the issues in the provided use cases (concatenation, inserting into UI, etc) are at the fault of the developer and not GetProductInfo.

2 Likes

When printing the contents of a TextBox with no text, it prints an empty string. So empty text boxes on the website SHOULD return the same result. No logical reason to return nil. Nil would imply a failed result.

1 Like

nil implies the absence of a value, not a failed result. An error implies a failed result. If there is no description, nil should be used.

1 Like

Why do TextBoxes return empty strings? Empty string is not an absent value. When you insert a StringValue, it comes as an empty string. Not a nil value

The nature of a TextBox and a StringValue is that these are containers for values that must be present - therefore, they are not optional. A description is different because it’s not a mandatory value. A StringValue always needs to contain a string.

“” is still a string. Descriptions should act in the same light as these objects. They are in essence the exact same thing, just on site. Nil should be returned for say PriceInRobux when an item isn’t for sale. But an empty string is not a nil value, under any circumstance

1 Like

Not all assets have descriptions, just like not all assets are on sale. Why should it be different for Description?

I’m unsure what assets on Roblox do not have descriptions available to them.

That’s actually a good question. I just checked and I’m not totally sure if this is ever the case for assets.

But in your code snippet, you’re using InfoType.Product. I just tested and when you have a devproduct with an empty description, like this:

image

…it comes out as nil. This is what happens when you feed the above product into this:

print(game.MarketplaceService:GetProductInfo(1260231231, Enum.InfoType.Product))

I think what you should be requesting is for the docs to be clarified - instead of saying “The description as shown on the asset’s page; can be nil if blank” it should be more clear about how it can be nil for certain info types.

I believe clearer documentation could be a better solution, or at least I would’ve never thought of its behavior, considering how lots of Roblox’s API seems to be with types and whatnot.

Like for example, sorta different, but this gamepass web API returns an empty string "", instead of nil.

https://api.roblox.com/marketplace/game-pass-product-info?gamePassId=4481584

I myself just assumed that the description was empty, not nonexistent, so it didn’t make sense to me personally for it to be nil.

You could look at it that way. It’s an inconsistency with how optional strings are treated across the different item types on Roblox - game passes, developer products, assets, etc. that becomes especially apparent when the docs try to make it seem like Description and other fields are just the same on all of the item types, when they behave differently.

I personally do not like how these are all under the same GetProductInfo function - I’d prefer individual functions like GetAssetInfo, GetDeveloperProductInfo, etc - then it’s nicer and cleaner in code without the unnecessary enum. Maybe that’s worth a separate feature request! :face_with_monocle:

3 Likes