Skip to content

Conversation

@zehata
Copy link
Contributor

@zehata zehata commented Dec 30, 2025

Updated the validation logic in the export service

Context

Resolves https://t.me/NUSMods/13264
This was caused by the validation logic in

const timetableSchema = Joi.object().pattern(
Joi.string(),
Joi.object().pattern(Joi.string(), Joi.string()),
);
const taModulesConfigSchema = Joi.object().pattern(
Joi.string(),
Joi.array().items(Joi.array().length(2).ordered(Joi.string(), Joi.string())),
);
not updated for the updated in timetable config schema.

The systemic problem is that there is currently no test coverage for the export service. It also took a long time to fix because the readme is really outdated.

Other Information

Sample image and pdf output of the export service, showing no regression from before #4225:
My Timetable.pdf
My Timetable

Updated the validation logic in the export service
@vercel
Copy link

vercel bot commented Dec 30, 2025

@zehata is attempting to deploy a commit to the modsbot's projects Team on Vercel.

A member of the Team first needs to authorize it.

@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.78%. Comparing base (988c6fd) to head (e28833b).
⚠️ Report is 157 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4277      +/-   ##
==========================================
+ Coverage   54.52%   56.78%   +2.26%     
==========================================
  Files         274      297      +23     
  Lines        6076     6924     +848     
  Branches     1455     1671     +216     
==========================================
+ Hits         3313     3932     +619     
- Misses       2763     2992     +229     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vercel
Copy link

vercel bot commented Jan 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
nusmods-export Ready Ready Preview, Comment Jan 1, 2026 6:29am
nusmods-website Ready Ready Preview, Comment Jan 1, 2026 6:29am

@leslieyip02
Copy link
Member

Yeah the export service is quite old and the testing issue was raised in #3926. We should probably do something about it.

Copy link
Member

@leslieyip02 leslieyip02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@leslieyip02 leslieyip02 merged commit 9d27927 into nusmodifications:master Jan 1, 2026
6 checks passed
@leslieyip02
Copy link
Member

For future reference, we missed 3 issues:

  1. .positive() expects a lesson index greater than 0, so it flags lesson indices of 0 as invalid
  2. .ordered() will restrict the lesson indices array's length, so we should use .items() instead
  3. Default value of the ta key in the export state should be [] instead of {}

Fixed by these commits: (this is pretty sloppy but I just wanted to get it fixed)

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.

2 participants