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

DateTimeParseException when retrieving AssignmentOverrides #160

Open
dnmilne opened this issue Jul 19, 2024 · 0 comments
Open

DateTimeParseException when retrieving AssignmentOverrides #160

dnmilne opened this issue Jul 19, 2024 · 0 comments

Comments

@dnmilne
Copy link

dnmilne commented Jul 19, 2024

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:

  1. Edit the getDefaultGsonParser in edu.ksu.canvas.impl.GsonResponseParser to have another fallback to handle these date formats.
  2. Turn the AssignmentOverride.allDayDate field into a String instead of a Date.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant