Skip to content

Commit b5637fe

Browse files
committed
fix(edit): handle empty cached search snapshots
1 parent aa14123 commit b5637fe

3 files changed

Lines changed: 4 additions & 0 deletions

File tree

docs/changes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Weblate 2026.7
3939
* Project and workspace translation license defaults now follow component and project licenses more closely.
4040
* Component and category API ``PATCH`` requests no longer remove the category when the field is omitted.
4141
* Hardened HTML and AJAX object lookups against private project enumeration.
42+
* Out-of-range cached search offsets no longer cause translate form submissions to fail.
4243
* Document and translation-memory uploads now enforce :setting:`TRANSLATION_UPLOAD_MAX_SIZE`, and API document uploads validate file extensions.
4344
* :ref:`check-rst-syntax` now detects inline roles wrapped in stray backticks.
4445
* :ref:`auto-translation` no longer validates hidden component fields when using machine translation.

weblate/trans/tests/test_edit.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def test_search_session_snapshot_handles_full_and_partial_windows(self) -> None:
102102
{"partial_ids": [10, 11], "partial_offset": 3}, 2, 1
103103
)
104104
)
105+
self.assertIsNone(get_search_session_snapshot({"ids": [1, 2, 3]}, 5, 1))
105106

106107
def test_search_session_snapshot_rejects_malformed_ids(self) -> None:
107108
self.assertIsNone(get_search_session_snapshot({"ids": ["invalid"]}, 1, 1))

weblate/trans/views/edit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ def get_search_session_snapshot(
457457
offset = max(len(unit_ids) - page_size + 1, 1)
458458
page_offset = offset - 1
459459
page_ids = unit_ids[page_offset : page_offset + page_size + 1]
460+
if not page_ids:
461+
return None
460462
return SearchSnapshot(
461463
ids=page_ids,
462464
offset=offset,

0 commit comments

Comments
 (0)