Repository navigation
fix: correct ILIAS scraping and session handling bugs - #3
Merged
Merged
Conversation
Exercise tooling was largely non-functional against real courses: - list_exercise_assignments returned nothing for past or upcoming assignments. The overview URL omitted mode=all, and ILIAS only renders currently running assignments by default. - list_submitted_files, the upload form and the team screen resolved their URLs from ilAssignmentPresentationGUI, which redirects to the overview without the dynamic cmdNode those links need, producing a HTTP 500. They now read the overview page instead. - Deadlines were never parsed: ILIAS writes "4. Mai 2026, 08:00" and mixes full with abbreviated month names, not "04.05.2026". - Status could report "abgegeben" for a row saying "nicht abgegeben", because the positive substring was tested first. - remove_team_member only posted the confirmation step, so it never removed anybody while still reporting success. - Team and delete operations reported status "ok" even when ILIAS ignored the request; they now verify the change and report "unchanged" otherwise. - search_users did not URL-encode the search term. - rtoken was only read from the form action, never from the hidden field, leaving the CSRF token empty on some forms. - Three regex-extracted URLs skipped unescape() unlike the fourth. Repository handling: - download_file and get_file_content on a folder silently returned the first file contained in it, because _detect_file_url ignored the ref_id it was given. Containers now raise instead. - Uploaded .html files could never be downloaded: the guard rejected every text/html response as an ILIAS error page. Real downloads always carry a Content-Disposition filename, error pages never do. - Exercise objects were typed as the generic "item". Session handling: - An expired ILIAS session was never renewed. _logged_in was a one-way latch, so every later call silently parsed the login page. Requests now go through AuthService.get(), which re-authenticates once. - POST transport errors escaped several tools unhandled. - An unparsable calendar seed silently returned events for today. Also fixes the pre-existing ruff violations so CI passes, and grows the test suite from 10 to 31 cases.
mcp 2.0.0 removed create_connected_server_and_client_session from mcp.shared.memory, which tests/test_mcp_server.py imports, so a fresh install resolved to 2.0.0 and broke collection. Earlier CI runs were green only because they predate the 2.0.0 release. Pinning keeps the currently supported API; migrating to the 2.x interface is a separate change.
There was a problem hiding this comment.
Pull request overview
This PR fixes multiple real-world ILIAS scraping, repository download, and session-expiry handling issues that previously caused silent misbehavior (wrong/empty results) rather than surfaced errors, and expands unit/regression coverage around those behaviors.
Changes:
- Add
AuthService.get()with login-page detection + one-time re-authentication, and route several services’ GETs through it. - Fix repository file-vs-container resolution and improve file-download detection (including allowing real uploaded
.htmldownloads viaContent-Disposition). - Improve exercise tooling parsing and flows (German deadline formats, status substring collision, URL unescaping/selection, team-member confirmation flow) and add regression tests.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_repository_service.py | Adds regression tests for folder-vs-file download URL detection and Content-Disposition-based HTML download handling. |
| tests/test_exercise_service.py | Adds regression tests for confirmation-screen handling, deadline parsing, status parsing order, rtoken extraction, and URL unescaping. |
| tests/test_auth_service.py | Adds tests for login-page detection on expired sessions and avoiding false positives on binary responses. |
| src/services/repository_service.py | Prevents containers from being treated as files, tightens download URL detection, improves download HTML-page detection, and routes GET/downloads via AuthService.get(). |
| src/services/news_service.py | Routes dashboard news fetch through AuthService.get(). |
| src/services/exercise_service.py | Fixes multiple parsing/URL/CSRF/team-confirmation issues; introduces a _post helper but currently lacks login-page detection on POST. |
| src/services/course_service.py | Routes memberships fetch through AuthService.get(). |
| src/services/calendar_service.py | Routes calendar fetch through AuthService.get(). |
| src/services/auth_service.py | Adds relogin() and get() with login-page detection and one retry. |
| src/services/init.py | Reorders exports. |
| src/mcp_app/server.py | Validates calendar seed format to avoid silently returning the wrong day; uses local date when seed is empty. |
| src/core/config.py | Import-order adjustment. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+595
to
+599
| def _post(self, url: str, label: str, **kwargs: object) -> requests.Response: | ||
| """POST relative to the ILIAS base URL, surfacing transport errors.""" | ||
| kwargs.setdefault("timeout", self.settings.timeout_seconds) | ||
| kwargs.setdefault("allow_redirects", True) | ||
| try: |
DenizAltunkapan
approved these changes
Aug 30, 2026
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.
Summary
The exercise tooling was largely non-functional against real courses, and a
few repository/session bugs caused silently wrong results rather than errors.
Verified against a live ILIAS instance (Uni Stuttgart, SS26 courses).
Exercise tooling
_overview_urlomittedmode=alllist_exercise_assignmentsreturnedcount: 0for every past or upcoming assignment — ILIAS only renders running ones by defaultilAssignmentPresentationGUIcmdNodethose links carry → HTTP 500 onlist_submitted_files, uploads and team screens04.05.20264. Mai 2026, 08:00and mixes full with abbreviated month names → deadline always empty"abgegeben"tested before"nicht abgegeben"remove_team_memberposted onlycmd[confirmRemoveTeamMember]status: "ok"unconditionally"unchanged"search_usersdid not encodetermrtokenread only from the form actionunescape()&leaked into URLsRepository handling
_detect_file_url()accepted aref_idparameter and ignored it. A containerpage also lists its children's download links, so
download_file(<folder>)and
get_file_content(<folder>)silently returned the first file insidethe folder. Containers now raise instead.
.htmlfiles could never be downloaded — the guard rejected everytext/htmlresponse as an ILIAS error page. Real downloads always carry aContent-Dispositionfilename; UI and error pages never do."item"type despite drivingthe submission tools; they now crawl as
"exercise".Session handling
AuthService._logged_inwas a one-way latch, so an expired ILIAS session wasnever renewed and every later call silently parsed the login page. All five
services now fetch through
AuthService.get(), which detects the login pageand re-authenticates once.
ExerciseServicehad a_getwrapper but posted raw); added the matching_post.seedmadelist_calendar_eventssilently return today'sevents instead of erroring.
Verification
ruff check/ruff format --check/pytest/python -m buildall pass.The 9 ruff violations were pre-existing and are fixed here, so CI goes green.
folder-vs-file resolution, the German date formats, the status substring
collision, the login-page detection and the confirmation-screen handling.
Not verified
The four mutating tools —
submit_exercise_file,delete_submitted_files,add_team_member,remove_team_member— were not executed against the liveserver, since doing so would alter real submissions and teams. Their fixes are
derived from the observed HTML and covered by unit tests, but are unconfirmed
end-to-end. Worth a careful manual check on a throwaway assignment.
Dependency pin
mcp2.0.0 removedcreate_connected_server_and_client_sessionfrommcp.shared.memory, whichtests/test_mcp_server.pyimports. Since theconstraint was an open
mcp>=1.9.0, a fresh CI install resolved to 2.0.0 andfailed collection — unrelated to the changes here, and it would hit
mainonits next run too. Pinned to
<2.0.0; migrating to the 2.x interface is aseparate piece of work.
🤖 Generated with Claude Code