tl-its-umich-edu / tool-migration

App for migrating external (LTI) tools in Instructure's Canvas LMS.
1 stars 3 forks source link

handle HTTP 422 errors #30

Closed lsloan closed 1 year ago

lsloan commented 1 year ago

Handle errors like…

2023-10-17 02:59:05,705 | WARNING | before_sleep:65 | Retrying api.API.put in 0.0 seconds as it raised HTTPStatusError: Client error '422 Unprocessable Entity' for url 'https://umich.beta.instructure.com/api/v1/courses/40857/tabs/context_external_tool_15593?hidden=false&position=44'
For more information check: https://httpstatuses.com/422.

That error appears when the app is run with these parameters…

API_URL=https://umich.beta.instructure.com
WH_HOST=udw.prod.unizin.org
WH_PORT=5439
WH_NAME=dbx14by8tn
ACCOUNT_ID=112
ENROLLMENT_TERM_IDS_CSV=1
SOURCE_TOOL_ID=37063
TARGET_TOOL_ID=15593
lsloan commented 1 year ago

While working on this issue, I found that the errors returned from the Canvas API about LTI tools in course 40857 are…

{"errors":[{"field":"conclude_at","message":"End date cannot be before start date","error_code":null}]}

This is the same error that @jonespm saw when he accessed the course manually.

lsloan commented 1 year ago

When the exceptions are caught and handled, they will be logged as…

2023-10-17 13:49:40,649 | WARNING | api:86 | HTTP 422: PUT https://umich.beta.instructure.com/api/v1/courses/40857/tabs/context_external_tool_15593?hidden=false&position=44; response: '{"errors":[{"field":"conclude_at","message":"End date cannot be before start date","error_code":null}]}'
2023-10-17 13:49:41,266 | WARNING | api:86 | HTTP 422: PUT https://umich.beta.instructure.com/api/v1/courses/40857/tabs/context_external_tool_37063?hidden=true; response: '{"errors":[{"field":"conclude_at","message":"End date cannot be before start date","error_code":null}]}'
zqian commented 1 year ago

Did you get the error message when accessing the course site via Canvas beta UI?

jonespm commented 1 year ago

No, just when accessing a specific API to change tools in navigation on this course. This is some really old course that seems like it might have a data problem. We've avoided trying to fix it as we don't know if we could easily recreate the issue.