ucfopen / canvasapi

Python API wrapper for Instructure's Canvas LMS. Easily manage courses, users, gradebooks, and more.
https://pypi.python.org/pypi/canvasapi
MIT License
554 stars 173 forks source link

Pagination next_link breaking with get_new_quizzes #663

Closed stelpstraATeur closed 3 weeks ago

stelpstraATeur commented 4 weeks ago

Pagination is breaking showing the following message:

  File "C:\Python\Envs\test_env\lib\site-packages\canvasapi\paginated_list.py", line 49, in __iter__
    new_elements = self._grow()
  File "C:\Python\Envs\test_env\lib\site-packages\canvasapi\paginated_list.py", line 111, in _grow
    new_elements = self._get_next_page()
  File "C:\Python\Envs\test_env\lib\site-packages\canvasapi\paginated_list.py", line 84, in _get_next_page
    re.search(regex, next_link["url"]).group(1) if next_link else None
AttributeError: 'NoneType' object has no attribute 'group'

Course with less than 50 New Quizzes don't cause any issues, but it happens in the situations:

Steps to reproduce the behavior:

Environment information:

Could it be related to what is mentioned in this blog post Forthcoming Update to Canvas API Response Header Capitalization?

jonespm commented 3 weeks ago

I don't see that limit set anywhere in the documentation for new quizzes and possibly nobody tested with more than 50 quizzes.

So this should probably be changed in the code for new quizzes if that is the limit, but you can work around it locally by passing a per_page parameter to see if that fixes it

new_quizzes(per_page=50)