Added check for invalid cart passed from the client.