From e43f221b84b8371c430c1c2fe66653dc2294aa20 Mon Sep 17 00:00:00 2001 From: Lukas Gold Date: Tue, 16 Jun 2026 12:26:11 +0200 Subject: [PATCH 1/2] fix: prevent KeyError when wiki file does not exist in download fallback When the MediaWiki FileApi returns download-notfound, the exception raised inside the try block was silently caught by the broad `except Exception`, setting web_api_failed=True. The subsequent fallback then crashed with KeyError: 'url' because the file's imageinfo has no URL for non-existent files. Fix by using a flag instead of raising inside the try block. --- src/osw/controller/file/wiki.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/osw/controller/file/wiki.py b/src/osw/controller/file/wiki.py index f078af3..19e7643 100644 --- a/src/osw/controller/file/wiki.py +++ b/src/osw/controller/file/wiki.py @@ -40,6 +40,7 @@ def get(self) -> IO: # use web api full_title = f"{self.namespace}:{self.title}" web_api_failed = False + file_not_found = False response = None try: url = ( @@ -54,7 +55,7 @@ def get(self) -> IO: if api_error is not None: if api_error == "download-notfound": # File does not exist - raise Exception("File does not exist: " + full_title) + file_not_found = True elif api_error == "badvalue": # Extension FileApi not installed on the server web_api_failed = True @@ -64,6 +65,8 @@ def get(self) -> IO: except Exception: web_api_failed = True + if file_not_found: + raise Exception("File does not exist: " + full_title) if web_api_failed: # fallback: use direct download url = file.imageinfo["url"] From 62868a7e2d5491e3ac19dad357d3b1267d3054b9 Mon Sep 17 00:00:00 2001 From: Lukas Gold Date: Tue, 16 Jun 2026 12:27:15 +0200 Subject: [PATCH 2/2] chore: ignore accounts.pwd.yaml and remove duplicate gitignore entry Adds */accounts.pwd.yaml to prevent credential files from being staged, and removes the duplicate */osw_files/* entry that was auto-appended. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index bdbc610..7040c33 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,5 @@ playground # Automatically added by osw.auth.CredentialManager.save_credentials_to_file: */osw_files/* + +*/accounts.pwd.yaml