instructure / canvas-lms

The open LMS by Instructure, Inc.
https://github.com/instructure/canvas-lms/wiki
GNU Affero General Public License v3.0
5.4k stars 2.42k forks source link

QTY-7536: Safely access methods from response body #2362

Closed tylerCaineRhodes closed 3 weeks ago

tylerCaineRhodes commented 3 weeks ago

Here is the link for the bug in Jira.

This is happening when we try to access properties on a non-existent key in the response body. Our guard clause is ultimately what is throwing this exception:

submission.submitted_at = turnitin_client.uploaded_at if turnitin_client.uploaded_at

Here uploaded_at is throwing the issue with the following code because meta is not present in this case:

response.body['meta']['date_uploaded']

I have created a method to always return nil in these cases in order for these methods to behave as expected.

CLAassistant commented 3 weeks ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 7 committers have signed the CLA.

:white_check_mark: tpaulshippy
:x: adiaz04
:x: jothankele
:x: QwertyTalk
:x: BostonEssary
:x: tylerCaineRhodes
:x: AliArehart
You have signed the CLA already but the status is still pending? Let us recheck it.