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

SAK-50711 Calendar first xhr request /direct/calendar/site/siteid.json returns invalid json #13056

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hornersa
Copy link
Contributor

Jira: https://sakaiproject.atlassian.net/browse/SAK-50711

I demo and explain the approach of this proposed fix in the video, SAK-50711-ProposedFix-20241122.mp4, attached to the jira.

@ern ern changed the title SAK-50711 Calendar: sakai-calendar.js console error(s) after start-up SAK-50711 Calendar xhr request /direct/calendar/site/${siteId}.json returns invalid json on first request Nov 22, 2024
@ern
Copy link
Contributor

ern commented Nov 22, 2024

@hornersa while I understand your logic here is to retry the fetch can you work out why the first request fails?

@ottenhoff
Copy link
Contributor

Yes, sorry, not a fan of this type of solution

@hornersa
Copy link
Contributor Author

@ern @ottenhoff - Can y'all point me to where in the code the REST call is being served? I'm not (very) familiar with where/how calls to /direct URIs is routing calls to which classes.

@ottenhoff
Copy link
Contributor

Find the request in Chrome console -> Network -> Look at the response

{
    "entityPrefix": "calendar",
    "calendar_collection": [
        calendar: ED: ref=/calendar:display=aa:url=https://sakai.example/direct/calendar: props(0): dataOnly=false: data=CalendarEventDetails(location=,
        lastTime=20241122215959999,
        description=aaa,
        descriptionFormatted=<p>aaa</p>
, eventReference=/calendar/event/b7c54a14-d048-49 b9-846e-8356 ebcaf3aa/main/30762426-e540-4507-bd9d-7 c1b259b5df0,
        attachments=[])
    ]
}

calendar_collection obviously bad. do a refresh and now it's:

{"entityPrefix": "calendar", 
"calendar_collection": [
{
  "assignmentId": "",
  "attachments": [],
  "creator": "8c39209a-20ed-4ab5-a0d3-2ba5f28effbe",
  "description": "aaa",
  "descriptionFormatted": "<p>aaa<\/p>\n",
  "duration": 3600000,
  "eventIcon": "icon-calendar-activity",
  "eventId": "30762426-e540-4507-bd9d-7c1b259b5df0",
  "eventReference": "\/calendar\/event\/b7c54a14-d048-49b9-846e-8356ebcaf3aa\/main\/30762426-e540-4507-bd9d-7c1b259b5df0",
  "firstTime": {
    "display": "Nov 22, 2024, 4:00 pm",
    "time": 1732309200000
  },
  "lastTime": {
    "display": "Nov 22, 2024, 4:59 pm",
    "time": 1732312799999
  },
  "location": "",
  "recurrenceRule": null,
  "reference": "\/calendar\/calendar\/b7c54a14-d048-49b9-846e-8356ebcaf3aa\/main",
  "siteId": "b7c54a14-d048-49b9-846e-8356ebcaf3aa",
  "siteName": "SMPL101 Summer 2024",
  "title": "aa",
  "type": "Activity",
  "entityReference": "\/calendar",
  "entityURL": "https:\/\/sakai.example\/direct\/calendar",
  "entityTitle": "aa"
}
]}

git grep -i calendar_collection

then i look at that line using tig:

tig blame calendar/calendar-tool/tool/src/webapp/js/sakai-calendar.js

@hornersa
Copy link
Contributor Author

@ottenhoff - Thanks, but I think I eventually found what I was looking for on the server site-- specifically that CalendarEventEntityProvider.getCalendarEventsForSite as the service method responding to the REST call. Presumably this is happening via the @EntityCustomAction annotation (presumably custom to Sakai) which I haven't delved into before. Nevertheless, I think I may have enough leads to pursue this further for now.

@hornersa hornersa marked this pull request as draft November 22, 2024 21:42
@hornersa
Copy link
Contributor Author

I've ascertained that the problem is not due to the List object returned by CalendarEventEntityProvider.java.getCalendarEventsForSite when invoked for the first time. In other words, the list has events if you follow the test plan.

Therefore, the problem is likely somewhere within whatever RESTful architecture is being used by Sakai and/or an initialization problem with the custom annotation, EntityCustomAction... perhaps. That is to say that this bug is currently too far into the weeds for me to dig much further.

@ern ern changed the title SAK-50711 Calendar xhr request /direct/calendar/site/${siteId}.json returns invalid json on first request SAK-50711 Calendar first xhr request /direct/calendar/site/siteid.json returns invalid json Nov 26, 2024
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

Successfully merging this pull request may close these issues.

3 participants