Course error: ValueError: min() arg is an empty sequence

To give you a background on what we have accomplished, our server was from native. We’ve gradually migrated it into tutor up to its latest version (currently Olive).

After that, we’ve attempted to activate the ecommerce plugin. And then we’ve encountered some error indicated here.

But now we’ve manged to fix the ecommerce error and installed it successfully. Upon checking our server, we noticed that some of our courses kept having a 500 error as the image below.

Using the command tutor local logs --tail=100 -f, We’ve ran through this error.

lms_1                        | 2023-03-08 05:28:50,069 ERROR 6 [root] [user None] [ip None] signals.py:22 - Uncaught exception from None
lms_1                        | Traceback (most recent call last):
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
lms_1                        |     response = get_response(request)
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
lms_1                        |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
lms_1                        |   File "/opt/pyenv/versions/3.8.12/lib/python3.8/contextlib.py", line 75, in inner
lms_1                        |     return func(*args, **kwds)
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
lms_1                        |     response = view_func(request, *args, **kwargs)
lms_1                        |   File "/openedx/edx-platform/common/djangoapps/util/views.py", line 43, in inner
lms_1                        |     response = view_func(request, *args, **kwargs)
lms_1                        |   File "/openedx/edx-platform/common/djangoapps/util/cache.py", line 90, in wrapper
lms_1                        |     return view_func(request, *args, **kwargs)
lms_1                        |   File "/openedx/edx-platform/./lms/djangoapps/courseware/views/views.py", line 810, in course_about
lms_1                        |     registration_price, course_price = get_course_prices(course)  # lint-amnesty, pylint: disable=unused-variable
lms_1                        |   File "/openedx/edx-platform/common/djangoapps/course_modes/models.py", line 860, in get_course_prices
lms_1                        |     registration_price = CourseMode.min_course_price_for_currency(
lms_1                        |   File "/openedx/edx-platform/common/djangoapps/course_modes/models.py", line 777, in min_course_price_for_currency
lms_1                        |     return min(mode.min_price for mode in modes if mode.currency.lower() == currency.lower())
lms_1                        | ValueError: min() arg is an empty sequence
lms_1                        | 2023-03-08 05:28:50,124 ERROR 6 [django.request] [user 149781] [ip 112.206.98.235] log.py:224 - Internal Server Error: /courses/course-v1:Coursebank+GD005+2023_Q1/about
lms_1                        | Traceback (most recent call last):
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
lms_1                        |     response = get_response(request)
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
lms_1                        |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
lms_1                        |   File "/opt/pyenv/versions/3.8.12/lib/python3.8/contextlib.py", line 75, in inner
lms_1                        |     return func(*args, **kwds)
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
lms_1                        |     response = view_func(request, *args, **kwargs)
lms_1                        |   File "/openedx/edx-platform/common/djangoapps/util/views.py", line 43, in inner
lms_1                        |     response = view_func(request, *args, **kwargs)
lms_1                        |   File "/openedx/edx-platform/common/djangoapps/util/cache.py", line 90, in wrapper
lms_1                        |     return view_func(request, *args, **kwargs)
lms_1                        |   File "/openedx/edx-platform/./lms/djangoapps/courseware/views/views.py", line 810, in course_about
lms_1                        |     registration_price, course_price = get_course_prices(course)  # lint-amnesty, pylint: disable=unused-variable
lms_1                        |   File "/openedx/edx-platform/common/djangoapps/course_modes/models.py", line 860, in get_course_prices
lms_1                        |     registration_price = CourseMode.min_course_price_for_currency(
lms_1                        |   File "/openedx/edx-platform/common/djangoapps/course_modes/models.py", line 777, in min_course_price_for_currency
lms_1                        |     return min(mode.min_price for mode in modes if mode.currency.lower() == currency.lower())
lms_1                        | ValueError: min() arg is an empty sequence
caddy_1                      | {"level":"error","ts":1678253330.2076666,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"112.206.98.235","remote_port":"48642","proto":"HTTP/2.0","method":"GET","host":"tmtg-clone.click","uri":"/courses/course-v1:Coursebank+GD005+2023_Q1/about","tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"tmtg-clone.click"}},"user_id":"","duration":0.211037908,"size":3277,"status":500}
lms_1                        | [pid: 6|app: 0|req: 130/425] 172.19.0.6 () {62 vars in 2698 bytes} [Wed Mar  8 05:28:49 2023] GET /courses/course-v1:Coursebank+GD005+2023_Q1/about => generated 9903 bytes in 210 msecs (HTTP/1.1 500) 7 headers in 523 bytes (1 switches on core 0)

We’ve spent a couple of days resolving this issue but sad to say, we haven’t progressed ever since. I need assistance from veterans.

Hi @Engr_James_Lusuegro

The error message pops up when the currency is not configured properly. It is essential to ensure that you have used the same currency throughout the entire platform. In case you are using multiple currencies, you may face this error.

To fix this issue, head over to the course_mode module in the Django admin panel (/admin/course_modes/coursemode/) and make sure that you have used the same currency for all your courses.

Furthermore, verify that you have used the same currency in your LMS Admin settings at /admin/course_modes/coursemode/ and the following parameters in settings:

  • PAID_COURSE_REGISTRATION_CURRENCY
  • COURSE_MODE_DEFAULTS

Hope this helps!

1 Like

Thank you for your quick reply. May I ask for your assistance on how can I view the said parameters in my settings?
Also, let’s assume that your theory is correct, how can I change the configuration in my settings?
I’m quite new to tutor so please bear with my low level programming skills. :sweat_smile:

hello @Engr_James_Lusuegro Welcome to the community
first, go to /admin/course_modes/coursemode/ and see your course like this

and for another help, you need to see how to check right so please follow this doc for

  • PAID_COURSE_REGISTRATION_CURRENCY
  • COURSE_MODE_DEFAULTS

I hope it can help you better and ensure that you have used the same currency throughout the entire platform.

Thank you for all your replies @Mahendra and @Yagnesh .

I’ve noticed that in our native installed version of ecommerce, we were using PHP as an ecommerce currency while the new installed ecommerce tutor plugin’s currency was set to USD by default.
I wouldn’t figure it out it weren’t for your replies.

So I’ve added ECOMMERCE_CURRENCY: PHP into my config.yml file, saved it via tutor config save, then relaunched it via tutor local launch.

Now the courses are loading properly. Thank you!

it’s nice to hear your problem is solved only one of my suggestions for the tutor it’s not a good habit to add directly in the config.yml file on behalf of u can make one plugin and enable that plugin so it’s good.

https://docs.tutor.overhang.io/tutorials/plugin.html

Thank you for this suggestion. But isn’t it a little too complicated if I would create a plugin just for the purpose of adding ECOMMERCE_CURRENCY: PHP into my config.yml file?