fix message errors - #757
Open
simonLeary42 wants to merge 12 commits into
Open
Conversation
simonLeary42
force-pushed
the
fix-message-bug
branch
from
July 16, 2026 15:56
d6743d0 to
16f3d8f
Compare
simonLeary42
force-pushed
the
fix-message-bug
branch
from
July 16, 2026 16:08
a56976b to
20765e2
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses message-clearing and AJAX error handling issues in the account portal by making message clearing idempotent, preventing redirects during AJAX error handling, and making redirect semantics explicit with respect to HTTP method preservation.
Changes:
- Adds a new idempotent AJAX endpoint for clearing all messages and updates the UI logic to use it instead of programmatically clicking each dismiss button.
- Updates
UnityHTTPD::redirect()to preserve the request method by default (307) and introducesredirectOverrideMethodGet()(303) for explicit POST→GET PRG redirects; updates call sites accordingly. - Adds request method assertions (
assertRequestMethod) and enforces POST-only access for POST data reads and specific endpoints.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| webroot/panel/pi.php | Uses explicit POST→GET redirect helper after PI actions. |
| webroot/panel/new_account.php | Uses explicit POST→GET redirect helper after registration. |
| webroot/panel/groups.php | Uses explicit POST→GET redirect helper for group membership actions. |
| webroot/panel/disabled_account.php | Uses explicit POST→GET redirect helper after re-enabling an account. |
| webroot/panel/ajax/clear_messages.php | Adds new POST-only endpoint to clear session messages. |
| webroot/panel/account.php | Uses explicit POST→GET redirect helper after account-setting actions. |
| webroot/lan/api/bump-last-login.php | Replaces manual method check with assertRequestMethod("POST"). |
| webroot/js/messages.js | Updates message dismissal UX; adds new “clear all” AJAX flow and frontend visibility logic. |
| webroot/admin/user-mgmt.php | Uses explicit POST→GET redirect helper after “view as user”. |
| webroot/admin/pi-mgmt.php | Uses explicit POST→GET redirect helper after PI group disable attempt. |
| resources/templates/header.php | Uses explicit POST→GET redirect helper for global PRG handling; avoids redirects for admin clearView flow. |
| resources/templates/header.html.twig | Always renders the Clear All Messages button (initially hidden); relies on JS to show/hide. |
| resources/lib/UnityHTTPD.php | Adds redirectOverrideMethodGet, changes redirect status codes (307/303), skips redirects for AJAX in gracefulDie, adds assertRequestMethod, and enforces POST method in getPostData. |
| deployment/config.base.ini | Bumps upstream version to 1.7.5. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
simonLeary42
force-pushed
the
fix-message-bug
branch
from
July 16, 2026 17:46
76c6edd to
e532351
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
here is the error log:
here are those same lines json prettified:
[ { "message": "", "error": { "class": "UnityWebPortal\\\\lib\\\\exceptions\\\\UnityHTTPDMessageNotFoundException", "msg": "message(level='success' title='SSH Key Added' body='Fingerprint: /J1uR4'), not found. found messages: []", "location": "/srv/www/unity-web-2026-7-15/resources/lib/UnityHTTPD.php:383", "trace": [ "#0 /srv/www/unity-web-2026-7-15/resources/lib/UnityHTTPD.php(405): UnityWebPortal\\\\lib\\\\UnityHTTPD::getMessageIndex()", "#1 /srv/www/unity-web-2026-7-15/webroot/panel/ajax/delete_message.php(12): UnityWebPortal\\\\lib\\\\UnityHTTPD::deleteMessage()", "#2 {main}" ] } }, { "message": "", "error": { "class": "UnityWebPortal\\\\lib\\\\exceptions\\\\UnityHTTPDMessageNotFoundException", "msg": "message(level='success' title='SSH Key Removed' body='ssh-ed2551...iTBc REDACTED'), not found. found messages: [[\\"An internal server error has occurred.\\",\\"For assistance, contact a Unity admin at hpc@umass.edu.\\\\nError ID: 6a5850f4c1aca\\",\\"error\\"]]", "location": "/srv/www/unity-web-2026-7-15/resources/lib/UnityHTTPD.php:383", "trace": [ "#0 /srv/www/unity-web-2026-7-15/resources/lib/UnityHTTPD.php(405): UnityWebPortal\\\\lib\\\\UnityHTTPD::getMessageIndex()", "#1 /srv/www/unity-web-2026-7-15/webroot/panel/ajax/delete_message.php(12): UnityWebPortal\\\\lib\\\\UnityHTTPD::deleteMessage()", "#2 {main}" ] } }, { "message": "", "error": { "class": "UnityWebPortal\\\\lib\\\\exceptions\\\\UnityHTTPDMessageNotFoundException", "msg": "message(level='success' title='SSH Key Added' body='Fingerprint: hbKNhr'), not found. found messages: [[\\"An internal server error has occurred.\\",\\"For assistance, contact a Unity admin at hpc@umass.edu.\\\\nError ID: 6a5850f4c1aca\\",\\"error\\"],[\\"An internal server error has occurred.\\",\\"For assistance, contact a Unity admin at hpc@umass.edu.\\\\nError ID: 6a5850f4c2b35\\",\\"error\\"]]", "location": "/srv/www/unity-web-2026-7-15/resources/lib/UnityHTTPD.php:383", "trace": [ "#0 /srv/www/unity-web-2026-7-15/resources/lib/UnityHTTPD.php(405): UnityWebPortal\\\\lib\\\\UnityHTTPD::getMessageIndex()", "#1 /srv/www/unity-web-2026-7-15/webroot/panel/ajax/delete_message.php(12): UnityWebPortal\\\\lib\\\\UnityHTTPD::deleteMessage()", "#2 {main}" ] } }, { "message": "$_POST has no array key 'level'", "trace": [ "#0 /srv/www/unity-web-2026-7-15/resources/lib/UnityHTTPD.php(81): UnityWebPortal\\\\lib\\\\UnityHTTPD::errorLog()", "#1 /srv/www/unity-web-2026-7-15/resources/lib/UnityHTTPD.php(174): UnityWebPortal\\\\lib\\\\UnityHTTPD::gracefulDie()", "#2 /srv/www/unity-web-2026-7-15/resources/lib/UnityHTTPD.php(245): UnityWebPortal\\\\lib\\\\UnityHTTPD::badRequest()", "#3 /srv/www/unity-web-2026-7-15/webroot/panel/ajax/delete_message.php(8): UnityWebPortal\\\\lib\\\\UnityHTTPD::getPostData()", "#4 {main}" ] }, { "message": "$_POST has no array key 'level'", "trace": [ "#0 /srv/www/unity-web-2026-7-15/resources/lib/UnityHTTPD.php(81): UnityWebPortal\\\\lib\\\\UnityHTTPD::errorLog()", "#1 /srv/www/unity-web-2026-7-15/resources/lib/UnityHTTPD.php(174): UnityWebPortal\\\\lib\\\\UnityHTTPD::gracefulDie()", "#2 /srv/www/unity-web-2026-7-15/resources/lib/UnityHTTPD.php(245): UnityWebPortal\\\\lib\\\\UnityHTTPD::badRequest()", "#3 /srv/www/unity-web-2026-7-15/webroot/panel/ajax/delete_message.php(8): UnityWebPortal\\\\lib\\\\UnityHTTPD::getPostData()", "#4 {main}" ] }, { "message": "$_POST has no array key 'level'", "trace": [ "#0 /srv/www/unity-web-2026-7-15/resources/lib/UnityHTTPD.php(81): UnityWebPortal\\\\lib\\\\UnityHTTPD::errorLog()", "#1 /srv/www/unity-web-2026-7-15/resources/lib/UnityHTTPD.php(174): UnityWebPortal\\\\lib\\\\UnityHTTPD::gracefulDie()", "#2 /srv/www/unity-web-2026-7-15/resources/lib/UnityHTTPD.php(245): UnityWebPortal\\\\lib\\\\UnityHTTPD::badRequest()", "#3 /srv/www/unity-web-2026-7-15/webroot/panel/ajax/delete_message.php(8): UnityWebPortal\\\\lib\\\\UnityHTTPD::getPostData()", "#4 {main}" ] } ]there's a lot that went wrong here:
clear messagesbutton (I think)clear messagesbutton's JS handler looped over each message and clicked eachXbutton, twiceUnityHTTPD::gracefulDie()caught the error, saw that there was a POST going on, and sent a redirect (nevermind the fact that the request was not for a webpage but an ajax endpoint)fixed:
clear messagesbutton no longer loops over the other buttons, instead it calls a new AJAX endpoint which is much simpler and is idempotentUnityHTTPD::gracefulDie()shall not redirect on ajax pagesgetQueryParameter(),getPostData()now expose the contents of the array for debugging when an array key is not foundnot fixed:
UnityHTTPD::gracefulDie()still changes request method from POST to GETredirectOverrideMethodGet()to make it explicit what is going on, and changed the underlyingredirect()so that the default behavior is to preserve the request methodXbutton on an individual message and get a new error messagedelete_message.php/UnityHTTPD::deleteMessage()idempotent, but this feels wrong because it could mask legitimate errorsalso changed:
Xbutton for a message will wait to hide elements it until the ajax request comes back successfulclear messagesbutton's visibility logic from backend to frontendhere is a demo where I have repurposed the
delete keybutton to send some messages instead:Screen.Recording.2026-07-16.at.1.35.18.PM.mov