Repository navigation
Conversation
TestPlatform.from_string raises EnumParsingException since CCExtractor#329, but /test/master/<platform>, /maintenance-mode/<platform> and /toggle_maintenance/<platform>/<status> still caught ValueError, so an unknown platform returned a 500 instead of the handled response. The existing test for /maintenance-mode used a wrong URL and assertIsNotNone, so it passed without reaching the route.
kaihere14
requested review from
canihavesomecoffee and
thealphadollar
as code owners
November 28, 2026 16:18
|
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.



In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
The problem
Three pages take a platform name in the URL, like
linuxorwindows. If you give a name that doesn't exist, each page is meant to handle it nicely. Instead, all three crash with a 500 server error./test/master/invalid/maintenance-mode/invalidERROR/toggle_maintenance/invalid/True(admin){"status": "failed", "message": "Platform Not found"}How to reproduce
Open any of the URLs above with a platform name that isn't
linuxorwindows. You get the 500 error page, and the log showsexceptions.EnumParsingException.Why it happens
These routes turn the name into a platform with
TestPlatform.from_string()and catchValueErrorif the name is wrong.But
from_string()indatabase.pydoesn't raiseValueError. Since #329 it raisesEnumParsingException, which is defined inexceptions.pyand is not aValueError. So theexcept ValueErrorlines never run, and the error crashes the page.The test that should have caught this didn't.
test_in_maintenance_mode_ValueErrorposted to/maintenance/invalid, which is the wrong URL, and checked the result withassertIsNotNone. That check passes for any response, so the test passed without ever reaching the route.The fix
Change
except ValueErrortoexcept EnumParsingExceptionin these three places:latest_commit_info()inmod_test/controllers.pytoggle_maintenance()andin_maintenance_mode()inmod_ci/controllers.pyNothing else changes. A valid platform name works exactly as before.
Tests
tests/test_ci/test_controllers.py: the broken test now uses the right URL and checks forERROR. It's renamed totest_in_maintenance_mode_invalid_platform.tests/test_ci/test_controllers.py: newtest_toggle_maintenance_invalid_platformchecks the "Platform Not found" response.tests/test_test/test_controllers.py: newtest_latest_commit_info_unknown_platformchecks for a 404.This touches the same file as #1276 (
mod_test/controllers.py), but a different line. I checked, and the two merge without conflicts.