From 68f84f978023de232b5e8e92c5b7a82dfc5f9f22 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 3 Jul 2025 18:51:38 +0000 Subject: [PATCH 1/3] Initial plan From 1c48af6c6644406ac1dc7f3de28e1a7820cf0a71 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 3 Jul 2025 18:57:27 +0000 Subject: [PATCH 2/3] Fix IndexError in folder namespace page_get_language method Co-authored-by: TrueBrain <1663690+TrueBrain@users.noreply.github.com> --- truewiki/namespaces/folder/namespace.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/truewiki/namespaces/folder/namespace.py b/truewiki/namespaces/folder/namespace.py index 9d3abf9..dd3f07d 100644 --- a/truewiki/namespaces/folder/namespace.py +++ b/truewiki/namespaces/folder/namespace.py @@ -90,7 +90,10 @@ def page_get_language(cls, page: str) -> Optional[str]: if cls._is_namespace_root(page): return None - return page.split("/")[2] + spage = page.split("/") + if len(spage) < 3: + return None + return spage[2] @staticmethod def get_used_on_pages(page: str) -> list: From 0fe0a3c951206497eedc1be9ffc3d723491d9f84 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 3 Jul 2025 19:11:02 +0000 Subject: [PATCH 3/3] Add e2e test for Folder/Category IndexError fix Co-authored-by: TrueBrain <1663690+TrueBrain@users.noreply.github.com> --- e2e/e2e_namespace_folder.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e/e2e_namespace_folder.py b/e2e/e2e_namespace_folder.py index 840282d..0391c8e 100644 --- a/e2e/e2e_namespace_folder.py +++ b/e2e/e2e_namespace_folder.py @@ -82,3 +82,16 @@ def test_folder_invalid_namespace(page: Page): expect( page.locator('text=Page name "Folder/Page2/Main Page" is in namespace "Page2" that does not exist.') ).to_be_visible() + + +def test_folder_category_no_crash(page: Page): + """Check that accessing Folder/Category doesn't cause an IndexError crash.""" + page.goto("http://localhost:8080/Folder/Category") + + # Before the fix, this would crash with an IndexError when page_get_language + # tried to access page.split("/")[2] on ["Folder", "Category"]. + # After the fix, it should show an appropriate error message. + # Since Category is a namespace, it should show the namespace error message. + expect( + page.locator('text=Page name "Folder/Category/Main Page" is in namespace "Category" that does not exist.') + ).to_be_visible()