Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Course Audit Log (course.query_audit_log()) breaks, possibly due to API change #667

Open
hanleybrand opened this issue Sep 4, 2024 · 0 comments
Labels

Comments

@hanleybrand
Copy link

Describe the bug

The following code fails:

course_id = 666666 
course = canvas.get_course(course_id)
logged_events = course.query_audit_by_course()
event_list = [e for e in logged_events]

fails with AttributeError: 'str' object has no attribute 'update' because (I believe) the API has been changed to return a JSON object with three-keys, the basic structure is:

{
    "links":  {},
    "events": [],
    "linked": {}
}

with the second key containing what used to be returned by the API (a list of CourseEvent objects)

To Reproduce

Run the above four lines with canvasapi==3.3.0 after substituting a valid course_id

Expected behavior

[e for e in course.query_audit_by_course()] would produce a list of CourseEvent objects

Fix

I was able to fix the issue by adding _root='events', to the PaginatedList args in Course.query_audit_by_course()

    def query_audit_by_course(self, **kwargs):

        return PaginatedList(
            CourseEvent,
            self._requester,
            "GET",
            "audit/course/courses/{}".format(self.id),
            _root='events',
            _kwargs=combine_kwargs(**kwargs),
        )

Environment information

  • Python version 3.9
  • CanvasAPI version 3.30
@hanleybrand hanleybrand added the bug label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant