Hi,
I faced the same in one of my commerce projects which was working fine with commerce-2.36 but after upgrading to 2.40 ver (the latest version) I got the same issue.
So as per the @rhovland in #2 🐛 Error on adding product to cart Needs work I checked all my custom codes and disabled all the modules and themes but I was still facing the same issue so I downgraded to commence-2.40 to 2.36 and its resolved my issue.
I also checked with 2.37. 2.38, 2.39 but I got the same problem.
So, it means that there is not an issue with the custom code but there is something that is passing incorrect values for anonymous sessions which is creating this issue.
Drupal: 10.3
PHP: 8.3
MariaDb: 10.11
I am reopening this issue as a bug for the 2.40 version.
Manav → created an issue.