Skip to content

[Bugfix:Forum] Fix category release dates#12458

Merged
bmcutler merged 19 commits into
Submitty:mainfrom
GarvitKhandelwal31:fix-forum-date-bug
Jun 4, 2026
Merged

[Bugfix:Forum] Fix category release dates#12458
bmcutler merged 19 commits into
Submitty:mainfrom
GarvitKhandelwal31:fix-forum-date-bug

Conversation

@GarvitKhandelwal31

@GarvitKhandelwal31 GarvitKhandelwal31 commented Feb 22, 2026

Copy link
Copy Markdown
Contributor

Why is this Change Important & Necessary?
Fixes #12327. Previously, when users submitted invalid dates while editing forum categories, the ForumController crashed with an InvalidArgumentException.

What is the New Behavior?
Forum category release dates now use a flatpickr date picker on both add and edit, with calendar opening on edit for easier selection.

What steps should a reviewer take to reproduce or test the bug or new feature?

  1. Log in to Submitty as an instructor/admin
  2. Navigate to discussion forum.
  3. Click the More dropdown menu and select Edit Categories

A) Reproduce the original crash (vulnerable code)

  1. git checkout main
  2. Go to the same edit categories page.
  3. Go to the network tab, add filters to fetch/xhr rather than all.
  4. Edit an already existing category and enter a valid date.
  5. Then go to the networks tab you will see
image 5) Now edit categories with an invalid date, say 'anydate'. 6) Go to the same networks tab and now you can see the error in the original issue- image

B) Verify this PR fixes the issue

  1. Now checkout this branch.
  2. Now you can see while adding a new category or even editing an existing category flatpickr calendar can be seen.
  3. Try adding category with empty date, or editing date, no error appears.
image

Automated Testing & Documentation

  • No new automated tests added
  • All changes maintain backward compatibility with existing functionality

Other information

@github-project-automation github-project-automation Bot moved this to Seeking Reviewer in Submitty Development Feb 22, 2026
@GarvitKhandelwal31 GarvitKhandelwal31 changed the title Fix forum category release date validation (Issue #12327) [Bugfix:Forum] Fix forum category release date validation Feb 23, 2026
@GarvitKhandelwal31 GarvitKhandelwal31 changed the title [Bugfix:Forum] Fix forum category release date validation [Bugfix] Fix forum category validation Feb 23, 2026
@GarvitKhandelwal31 GarvitKhandelwal31 changed the title [Bugfix] Fix forum category validation [Bugfix:Forum] Fix category release dates Feb 23, 2026
@codecov

codecov Bot commented Feb 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 21.67%. Comparing base (95d0a63) to head (04d2fdc).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##               main   #12458   +/-   ##
=========================================
  Coverage     21.67%   21.67%           
  Complexity     9802     9802           
=========================================
  Files           268      268           
  Lines         36724    36724           
  Branches        490      490           
=========================================
  Hits           7960     7960           
  Misses        28278    28278           
  Partials        486      486           
Flag Coverage Δ
autograder 21.32% <ø> (ø)
js 2.02% <ø> (ø)
migrator 100.00% <ø> (ø)
php 20.73% <ø> (ø)
python_submitty_utils 80.08% <ø> (ø)
submitty_daemon_jobs 91.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 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.

@GarvitKhandelwal31

Copy link
Copy Markdown
Contributor Author

Could a maintainer please approve the workflow runs? I've pushed fixes for the CI failures:

  • Fixed PHP code style error (Stroustrup brace style for catch statement)
  • Fixed Cypress test assertion errors

Thanks!

Comment thread site/package.json Outdated
@github-project-automation github-project-automation Bot moved this from Seeking Reviewer to Work in Progress in Submitty Development Feb 26, 2026
Copilot AI review requested due to automatic review settings March 1, 2026 16:09
@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to In Review in Submitty Development Mar 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a forum category “release date” crash by hardening backend date parsing and updating the categories UI to use a flatpickr-backed date picker, with new Cypress regression coverage.

Changes:

  • Add try/catch handling in ForumController::editCategory() to avoid InvalidArgumentException crashes on invalid dates.
  • Update the category date edit UI to use a flatpickr-enhanced input.
  • Add Cypress E2E tests covering category release date add/edit/clear flows (and bump Cypress in npm deps).

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
site/app/controllers/forum/ForumController.php Catches invalid date parsing during category edits and returns a JSON failure instead of crashing.
site/app/templates/forum/ShowCategories.twig Switches category date editing to a flatpickr-driven input and initializes flatpickr during edit interactions.
site/cypress/e2e/Cypress-Feature/forums.spec.js Adds regression tests for category release date creation/editing/clearing behavior.
site/package.json Bumps Cypress version.
site/package-lock.json Lockfile updates corresponding to the Cypress bump.
Files not reviewed (1)
  • site/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread site/package.json Outdated
Comment thread site/app/templates/forum/ShowCategories.twig Outdated
Comment thread site/app/controllers/forum/ForumController.php Outdated
Comment thread site/app/controllers/forum/ForumController.php Outdated
Comment thread site/cypress/e2e/Cypress-Feature/forums.spec.js Outdated
Comment thread site/package-lock.json Outdated
Comment thread site/app/templates/forum/ShowCategories.twig Outdated
Comment thread site/app/controllers/forum/ForumController.php Outdated
Comment thread site/cypress/e2e/Cypress-Feature/forums.spec.js Outdated
@GarvitKhandelwal31

Copy link
Copy Markdown
Contributor Author

@JManion32 Your requested changes have been addressed. Would appreciate another review from you whenever you are free.
Thanks!

@JManion32 JManion32 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please ensure package-lock.json has no changes. Please also update your pull request description to include images of your updates to the UI, and remove mentions of bumping Cypress / changing package.json and package-lock.json. Thank you!

@github-project-automation github-project-automation Bot moved this from In Review to Work in Progress in Submitty Development Mar 4, 2026
@GarvitKhandelwal31
GarvitKhandelwal31 force-pushed the fix-forum-date-bug branch 4 times, most recently from 5811e11 to 57c562a Compare March 5, 2026 21:24
@GarvitKhandelwal31

Copy link
Copy Markdown
Contributor Author

@JManion32 I have completely fixed this PR. I realized that previous file changes were completely unnecessary. Furthermore I have added detailed procedures on how to verify my fixes, along that I have also added screen recording.

Please have a look when you have time.

@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to In Review in Submitty Development Mar 5, 2026
…ase date (Issue Submitty#12327)

- Add validation for empty date strings in addNewCategory() and editCategory()
- Treat empty/whitespace-only dates as null (no release restriction)
- Wrap parseDateTime() calls in try-catch blocks to handle invalid formats
- Return user-friendly error messages instead of crashing
- Fix markPostUnread() to validate timestamp input
- Fix editThread() to handle empty/invalid lock dates and expiration dates

This prevents InvalidArgumentException when instructors leave release date fields empty or enter invalid date formats.

@JManion32 JManion32 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@GarvitKhandelwal31 were you able to reproduce the issue and get the error seen in #12327? Based on your instructions, it is unclear to me. Everything I have tried to reproduce on the error on main has worked as expected with no crashes. Please include instructions on exactly how to reproduce so I can verify that your changes are actually solving this issue. Thank you!

Comment thread site/app/controllers/forum/ForumController.php Outdated
@github-project-automation github-project-automation Bot moved this from In Review to Work in Progress in Submitty Development Mar 13, 2026
@GarvitKhandelwal31

GarvitKhandelwal31 commented Mar 29, 2026

Copy link
Copy Markdown
Contributor Author

@IDzyre Would be grateful for your review in this. I saw that there are more open PRs on this issue, so here my review on them-

Comparative Review: #12458 vs #12675 vs #12328

This comment focuses on shortcomings in #12675 and #12328, and how #12458 addresses them.

Shortcomings in #12675

  1. It only protects editCategory() and does not fix the category-creation path.

  2. UI state can become inconsistent on failed save (optimistic local update before server success).

Shortcomings in #12328

  1. Same create-path gap as [Bugfix:Forum] Handle invalid category date #12675 (addNewCategory() still unguarded).

  2. Test navigation is more brittle (cy.contains('Edit Categories')) instead of stable test-id target.

How #12458 fixes these

  1. Fixes both create and edit controller paths with validation + exception handling.
  • Evidence:
    • addNewCategory() hardened:

    • editCategory() hardened:

  1. Prevents stale client state after failed date edits by updating UI state on success path.
  • Evidence:
    • Avoids premature local mutation in template flow:

    • Applies state updates in success handler:

  1. Adds stable Cypress regression coverage for invalid category date flow (with test ids).

@IDzyre

IDzyre commented Mar 30, 2026

Copy link
Copy Markdown
Member

@IDzyre Would be grateful for your review in this. I saw that there are more open PRs on this issue, so here my review on them-

Comparative Review: #12458 vs #12675 vs #12328

This comment focuses on shortcomings in #12675 and #12328, and how #12458 addresses them.

Shortcomings in #12675

  1. It only protects editCategory() and does not fix the category-creation path.
  2. UI state can become inconsistent on failed save (optimistic local update before server success).

Shortcomings in #12328

  1. Same create-path gap as [Bugfix:Forum] Handle invalid category date #12675 (addNewCategory() still unguarded).
  2. Test navigation is more brittle (cy.contains('Edit Categories')) instead of stable test-id target.

How #12458 fixes these

  1. Fixes both create and edit controller paths with validation + exception handling.
  • Evidence:

    • addNewCategory() hardened:
    • editCategory() hardened:
  1. Prevents stale client state after failed date edits by updating UI state on success path.
  • Evidence:

    • Avoids premature local mutation in template flow:
    • Applies state updates in success handler:
  1. Adds stable Cypress regression coverage for invalid category date flow (with test ids).

I am flying back from a vacation today. I will see if I can look into it tomorrow, but no promises.

// Navigate to the category management page.
cy.get('[data-testid="more-dropdown"]').click();
cy.get('[data-testid="edit-categories-link"]').click();
cy.get('#manage-categories-view').should('be.visible');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a testid for this?

@IDzyre IDzyre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See comment about testid, and ensure this passes the tests in CI.

@github-project-automation github-project-automation Bot moved this from In Review to Work in Progress in Submitty Development Mar 31, 2026
@GarvitKhandelwal31

Copy link
Copy Markdown
Contributor Author

The 4 failures in late_submission_warning_messages.spec.js and gradeable_upload.spec.js are pre-existing flaky tests unrelated to this PR:

late_submission_warning_messages failures 2 & 4: day count is off-by-one when CI runs before noon (server timezone boundary issue in getDueDateString())
late_submission_warning_messages failures 1 & 3: #more_extension_popup not shown on retries due to no cleanup between Cypress retry attempts
gradeable_upload failure: api_testing gradeable persists from previous CI run — no teardown

If you would want I could open a separate PR and issue addressing them.

@github-actions github-actions Bot added the Abandoned PR - Needs New Owner No activity on PR for more than 2 weeks -- seeking new owner to complete label Apr 16, 2026

@Eli-J-Schwartz Eli-J-Schwartz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Most date entry systems on Submitty use flatpickr to choose well-formatted dates, including another date entry on the same page. Would it be possible to use flatpickr here too?

@GarvitKhandelwal31
GarvitKhandelwal31 marked this pull request as draft May 3, 2026 09:40
@GarvitKhandelwal31
GarvitKhandelwal31 marked this pull request as ready for review May 3, 2026 10:13
@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to Seeking Reviewer in Submitty Development May 3, 2026
@GarvitKhandelwal31

Copy link
Copy Markdown
Contributor Author

Most date entry systems on Submitty use flatpickr to choose well-formatted dates, including another date entry on the same page. Would it be possible to use flatpickr here too?

Done, please refer the updated description for the review.

@GarvitKhandelwal31 GarvitKhandelwal31 removed the Abandoned PR - Needs New Owner No activity on PR for more than 2 weeks -- seeking new owner to complete label May 19, 2026

@dandrecollins07-ctrl dandrecollins07-ctrl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Passes manual test cases.

Minor note: Invalid dates such as 2026-99-99 automatically roll over to 2034-06-07.
Approved.

@bmcutler
bmcutler merged commit 6d3a045 into Submitty:main Jun 4, 2026
25 of 26 checks passed
@github-project-automation github-project-automation Bot moved this from Seeking Reviewer to Done in Submitty Development Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

discussion forum category date bug

7 participants