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?
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
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.
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.
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
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.
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!