Reccomend to also check this topic: https://github.com/bizz84/SwiftyStoreKit/issues/592
One thing that can cause this error is having a subscription without a duration set in App Store Connect.
Its possible to go through the flow and set the price without a duration for some reason.
and
I figured it out. I was logged into my main apple id in the sandbox environment. To fix that, generate a sandbox apple id in app store connect, then login to the sandbox apple id you just created by going to Settings->App Store->Sandbox Account.