MarketplaceService:PlayerOwnsAsset() sometimes returns incorrect result

MarketplaceService:PlayerOwnsAsset(player, itemId) will incorrectly return false even if the player owns the itemId if the caller is being 429 rate limited on calls to MarketplaceService:getProductInfo(). While a 429 error is visually printed in output, it cannot be caught through a pcall as recommended in the reference documentation (the pcall always succeeds). Thus, there is no way for the developer to know that they should retry the request or whether the result is legitimate.

Repro (run in studio command line) in play mode:

local anItemThatIOwn = 10046007575
local player = game.Players:GetPlayers()[1]

local MarketplaceService = game:GetService("MarketplaceService")

print(MarketplaceService:PlayerOwnsAsset(player, anItemThatIOwn)) -- true

while true do
    local success, message = pcall(function()
        MarketplaceService:GetProductInfo(anItemThatIOwn)
    end)

    if not success and string.find(message, "429") then
        print("Got 429 rate limited on calls to MarketplaceService:GetProductInfo()")
        break
    else
        print("Successful request. Did not get rate limited.")
    end
end

local playerOwnsAssetCheck
success, message = pcall(function()
    playerOwnsAssetCheck = MarketplaceService:PlayerOwnsAsset(player, anItemThatIOwn)
end)

print(success, playerOwnsAssetCheck) -- true, false

Output:

A private message is associated with this bug report

3 Likes

try this

local player = game.Players:GetPlayers()[1]

local MarketplaceService = game:GetService("MarketplaceService")

print(MarketplaceService:PlayerOwnsAsset(player, anItemThatIOwn)) -- true

while true do
    local success, message = pcall(function()
        MarketplaceService:GetProductInfo(anItemThatIOwn)
    end)

    if not success and string.find(message, "429") then
        print("Got 429 rate limited on calls to MarketplaceService:GetProductInfo()")
        break
    else
        print("Successful request. Did not get rate limited.")
    end
end

local function safePlayerOwnsAsset(player, assetId)
    local maxRetries = 3
    local retryInterval = 5

    for retry = 1, maxRetries do
        local success, ownsAsset = pcall(function()
            return MarketplaceService:PlayerOwnsAsset(player, assetId)
        end)

        if success then
            return ownsAsset
        else
            local errorMessage = tostring(ownsAsset)
            if string.find(errorMessage, "429") then
                print("Got 429 rate limited on PlayerOwnsAsset(), retrying...")
                wait(retryInterval * retry)  -- Wait before retrying
            else
                print("Encountered an error:", errorMessage)
                return false
            end
        end
    end

    return false
end

local playerOwnsAssetCheck = safePlayerOwnsAsset(player, anItemThatIOwn)
print("Player owns asset:", playerOwnsAssetCheck)
1 Like

Thanks for the report! We’ll follow up when we have an update for you.

1 Like

Are there any updates to this? I am still having this issue.