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

feat: Detect changes coming from FCC API responses inside of the classroom mode project using a CRON job #410

Open
GuillermoFloresV opened this issue Jul 30, 2023 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@GuillermoFloresV
Copy link
Member

GuillermoFloresV commented Jul 30, 2023

Describe the bug
Recently, we came across an issue that seems to have originated from changes on the FCC backend. Our API processing file (/util/api_processor) started creating undefined data inside the allChallenges key inside our CreateDashboardObject function.

The fault came from attempting to access a zeroth index inside of our response object. We did some digging and found that the issue persists despite rolling back changes made to the processing file and files associated with it, leaving us with the assumption that this was caused by changes in the fcc API that we use to build and display classrooms.

To Reproduce
Steps to reproduce the behavior:
This issue will be patched by #401 however, we want to at the very least be more aware of changes happening on FCC's end so that we do not waste time figuring out what caused our code to break.

Expected behavior
We want to set up a cron job to ping the endpoints used by classroom mode and compare them to what the project is currently expecting. I found this article that walks through how to set one up using GitHub Actions, so it should be a good starting point. From there, if there is a change detected we want to display what it is and possibly alert the maintainers of the repo (or at the very least set up triggers for associated files) to alert contributors about the changes.

@GuillermoFloresV GuillermoFloresV added the enhancement New feature or request label Jul 30, 2023
@GuillermoFloresV GuillermoFloresV self-assigned this Jul 30, 2023
@lloydchang
Copy link
Contributor

@GuillermoFloresV @ngillux

Related to freeCodeCamp/classroom needing to make corresponding changes via #401

I believe the following changes in freeCodeCamp/freeCodeCamp impacted freeCodeCamp/classroom:


From freeCodeCamp/freeCodeCamp#50769 (review) by @ojeytonwilliams to @naomi-lgbt on June 28th:


It's not really relevant to this PR, but I wonder if we should switch the meta.json format from

"challengeOrder": [
[
"id": "587d7dbc367417b2b2512bb1",
"title": "Create a Simple JSX Element"
[,
to

"challengeOrder": [
{
"id": "587d7dbc367417b2b2512bb1",
"title": "Create a Simple JSX Element"
},
Working with tuples is nasty and, weirdly, I don't think much code needs to change to accommodate this. What do you reckon?

Anyways, back on topic, some nitpicks:


From freeCodeCamp/freeCodeCamp#50955 by @naomi-lgbt on July 12th:


As mentioned in freeCodeCamp/freeCodeCamp#50769 (review), this migrates the meta.json files to use objects instead of tuples.


@lloydchang
Copy link
Contributor

lloydchang commented Jul 31, 2023

@GuillermoFloresV @ngillux

I want to highlight that a JSON object is unordered by design based on the JSON standard in RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format

• When we request the FCC API that responds with a JSON object (instead of a tuple), the order isn't guaranteed.

• Item 0 in a JSON object probably won't be the same as item 0 in a tuple, and the ordering in the JSON response can change from one request to the next.

Therefore, when you implement:

We want to set up a job to ping the endpoints used by classroom mode and compare them to what the project is currently expecting. From there, if there is a change detected we want to display what it is and possibly alert the maintainers of the repo (or at the very least set up triggers for associated files) to alert contributors about the changes.

I believe you would need a JSON diff tool that understands semantics and ignores the ordering in the response.

Reference:

From https://datatracker.ietf.org/doc/html/rfc8259.html

An object is an unordered collection of zero or more name/value
pairs, where a name is a string and a value is a string, number,
boolean, null, object, or array.

An array is an ordered sequence of zero or more values.

Thank you!

@ojeytonwilliams
Copy link
Contributor

Sorry about this, I didn't realise that Classroom was relying on the shape of that data. I should have realised given that it changed the schema.

For the short term I'll try and keep that in mind. In the longer term the api-rewrite should handle this issue since any changes to the api will come with a change in the api version.

@Nirajn2311
Copy link
Member

Actually the challenge data is taken from the client static files.

@ojeytonwilliams
Copy link
Contributor

Right, but we changed that in freeCodeCamp/freeCodeCamp#50955

@Nirajn2311
Copy link
Member

Nirajn2311 commented Jul 31, 2023

Yup. I was pointing out this part

For the short term I'll try and keep that in mind. In the longer term the api-rewrite should handle this issue since any changes to the api will come with a change in the api version.

Classroom doesn't use the main API, it gets the challenge data from client static files

@ojeytonwilliams
Copy link
Contributor

Ah, good point.

Just to reiterate, once we have the new API up and running there should no longer be a need to rely on those static files since Classroom will be able to get whatever it needs from (hopefully) stable api endpoints.

@GuillermoFloresV GuillermoFloresV changed the title feat: Detect changes coming from FCC API responses inside of the classroom mode project feat: Detect changes coming from FCC API responses inside of the classroom mode project using a CRON job Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants