DateTimeParseException when retrieving AssignmentOverrides
Opened this issue · 0 comments
dnmilne commented
A DateTimeParseException
error is thrown whenever you attempt to retrieve assignment overrides for an assignment that actually has some overrides.
List<AssignmentOverride> overrides = reader.listAssignmentOverrides(courseId, assignmentId) ;
throws:
com.google.gson.JsonParseException: java.time.format.DateTimeParseException: Text '2024-08-20' could not be parsed at index 10
at edu.ksu.canvas.impl.GsonResponseParser$6.deserialize(GsonResponseParser.java:79) ~[canvas-api-2.0.0.jar:na]
at edu.ksu.canvas.impl.GsonResponseParser$6.deserialize(GsonResponseParser.java:67) ~[canvas-api-2.0.0.jar:na]
at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69) ~[gson-2.9.0.jar:na]
at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:63) ~[gson-2.9.0.jar:na]
...
The cause is the all_day_date
field, which is in the format "yyyy-MM-dd" (with no time or timezone data), and consequently cannot be parsed as a Date
by gson.
Two possible fixes:
- Edit the
getDefaultGsonParser
inedu.ksu.canvas.impl.GsonResponseParser
to have another fallback to handle these date formats. - Turn the
AssignmentOverride.allDayDate
field into aString
instead of aDate
.
I would lean towards option 2, since it would be unwise to treat this as a date anyway given that it has no timezone info.
Happy to write a pull request, but will anyone action it? This is a great repository but it seems like it has been dead for a few years now?