This is an automated email from the ASF dual-hosted git repository. gstein pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/steve.git
commit 0cc3fbd788d5e21c205a68d49ff06b7d1f356cd2 Author: Greg Stein <[email protected]> AuthorDate: Sat Oct 11 17:46:30 2025 -0500 Improve detection/handling of bad Election IDs. --- v3/server/pages.py | 12 ++++-------- v3/server/templates/e_bad_eid.ezt | 3 +++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/v3/server/pages.py b/v3/server/pages.py index 058b720..80b54dd 100644 --- a/v3/server/pages.py +++ b/v3/server/pages.py @@ -101,15 +101,9 @@ def load_election(func): @functools.wraps(func) async def loader(eid): - e = steve.election.Election(DB_FNAME, eid) - _LOGGER.debug(f'Loaded: {e}') - try: - md = e.get_metadata() - except AttributeError: - # If the EID is wrong, the fetch fails trying to access metadata. - ### YES, very poor way to signal a bad EID. fix this. - + e = steve.election.Election(DB_FNAME, eid) + except steve.election.ElectionNotFound: result = await signin_info() result.title = 'Unknown Election' result.eid = eid @@ -117,6 +111,8 @@ def load_election(func): raise_404(T_BAD_EID, result) # NOTREACHED + _LOGGER.debug(f'Loaded: {e}') + ### check authz return await func(e) diff --git a/v3/server/templates/e_bad_eid.ezt b/v3/server/templates/e_bad_eid.ezt index 50c8dbc..57cfd68 100644 --- a/v3/server/templates/e_bad_eid.ezt +++ b/v3/server/templates/e_bad_eid.ezt @@ -8,5 +8,8 @@ you have no issues to vote in that Election, or you are not allowed to manage that Election. </p> + <p> + <a href="/">Return to the home page</a> + </p> </div> [include "footer.ezt"]
