Skip to content
Merged
1 change: 1 addition & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Weblate 2026.12

.. rubric:: Bug fixes

* Fixed a false review-state conflict when saving your own edit again after using the browser's Back button in the translation editor.
* Removed the separate upload rate limit for :http:post:`REST translation uploads </api/translations/(string:project)/(string:component)/(string:language)/file/>`.
* Limited repository automation :ref:`alerts <alerts>` to components that own a remote repository and skipped screenshot coverage guidance for glossaries.
* Applied changes to :setting:`VCS_ALLOW_SCHEMES` and the :setting:`default Git committer <DEFAULT_COMMITER_NAME>` after restarting Weblate, including for existing repositories.
Expand Down
11 changes: 10 additions & 1 deletion weblate/trans/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,8 +932,17 @@ def clean(self) -> None:
initial_state is not None
and self.user_can_edit
and "suggest" not in self.data
and state_changed
):
unit.validate_review_state(initial_state)
# Allow repeated edits by the same author, matching the
# translationsum exemption above: when the user's own save
# changed the review state, tolerate the stale initial_state
# from a browser-cached form.
last_author = unit.get_last_content_change()[0]
if last_author == self.user:
self.cleaned_data["initial_state"] = unit.state
Comment on lines +975 to +977

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Check the review-state actor rather than the content author

When reviewer B accepts and approves a suggestion written by reviewer A, Suggestion.accept() records B as Change.user but A as Change.author. get_last_content_change() returns the latter, so if A still has an older editor form open, this branch incorrectly treats B's state change as A's own and replaces the expected state. A's stale save can then silently undo B's approval instead of reporting a conflict. Base the exemption on the actor of the actual state-changing history entry, not its content author.

AGENTS.md reference: AGENTS.md:L65-L66

Useful? React with 👍 / 👎.

Comment thread
nijel marked this conversation as resolved.
Resolved
else:
unit.validate_review_state(initial_state)

fuzzy_state = unit.state if unit.state in FUZZY_STATES else STATE_FUZZY

Expand Down
57 changes: 32 additions & 25 deletions weblate/trans/tests/test_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,36 +569,43 @@
}

def test_state_conflict_preserves_draft(self) -> None:
for actor in (self.user, self.anotheruser):
with self.subTest(actor=actor.username):
self.change_unit("Nazdar svete!\n", state=STATE_NEEDS_REWRITING)
self.change_unit("Nazdar svete!\n", state=STATE_TRANSLATED, user=actor)
change_count = Change.objects.filter(unit=self.unit).count()
for _attempt in range(2):
response = self.client.post(self.url, self.data)
self.assertContains(
response,
"The review state of this string has changed from "
"Needs editing (Needs rewriting) to Translated",
)
self.assertNotContains(
response, "This review state is not available"
)
self.assertNotContains(response, "Select a valid choice")
self.assertContains(response, self.data["target_0"])
self.assertContains(response, 'name="initial_state" value="11"')
self.assertContains(response, 'data-unsaved="true"')
self.unit.refresh_from_db()
self.assertEqual(self.unit.target, "Nazdar svete!\n")
self.assertEqual(self.unit.state, STATE_TRANSLATED)
self.assertEqual(
Change.objects.filter(unit=self.unit).count(), change_count
)
"""Another user changed the state: the stale form is rejected."""
self.change_unit("Nazdar svete!\n", state=STATE_NEEDS_REWRITING)
self.change_unit(
"Nazdar svete!\n", state=STATE_TRANSLATED, user=self.anotheruser
)
change_count = Change.objects.filter(unit=self.unit).count()
for _attempt in range(2):
response = self.client.post(self.url, self.data)
self.assertContains(
response,
"The review state of this string has changed from "
"Needs editing (Needs rewriting) to Translated",
)
self.assertNotContains(response, "This review state is not available")
self.assertNotContains(response, "Select a valid choice")
self.assertContains(response, self.data["target_0"])
self.assertContains(response, 'name="initial_state" value="11"')
self.assertContains(response, 'data-unsaved="true"')
self.unit.refresh_from_db()
self.assertEqual(self.unit.target, "Nazdar svete!\n")
self.assertEqual(self.unit.state, STATE_TRANSLATED)
self.assertEqual(Change.objects.filter(unit=self.unit).count(), change_count)

def test_state_conflict_same_author_allowed(self) -> None:
"""Same user changed the state (browser Back): the stale form is accepted."""
self.change_unit("Nazdar svete!\n", state=STATE_NEEDS_REWRITING)
self.change_unit("Nazdar svete!\n", state=STATE_TRANSLATED, user=self.user)
response = self.client.post(self.url, self.data)
self.assertEqual(response.status_code, 302)
Comment on lines +598 to +600

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update the remaining same-user conflict tests

The existing test_conflict_with_still_available_choice, test_zen_state_conflict, and Selenium's test_zen_review_state_conflict still expect same-user state changes to produce conflicts. The first two use change_unit() without an actor, which defaults to self.user; the Selenium test explicitly passes the logged-in user at weblate/trans/tests/test_selenium.py:2613. These submissions now succeed under the new exemption, so the unit tests fail their conflict assertions and the Selenium test times out waiting for a conflict toast. Use another user for those competing changes, or update their expectations to match the intended same-user behavior.

Useful? React with 👍 / 👎.

self.unit.refresh_from_db()
self.assertEqual(self.unit.target, self.data["target_0"])
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
self.assertEqual(self.unit.state, STATE_TRANSLATED)

def test_conflict_with_still_available_choice(self) -> None:
self.change_unit("Nazdar svete!\n", state=STATE_NEEDS_CHECKING)
response = self.client.post(self.url, {**self.data, "review": "20"})
self.assertContains(response, "The review state of this string has changed")

Check failure on line 608 in weblate/trans/tests/test_edit.py

View workflow job for this annotation

GitHub Actions / py3.14, latest deps

ReviewStateTest.test_conflict_with_still_available_choice AssertionError: 302 != 200 : Couldn't retrieve content: Response code was 302 (expected 200)

Check failure on line 608 in weblate/trans/tests/test_edit.py

View workflow job for this annotation

GitHub Actions / py3.12, latest deps

ReviewStateTest.test_conflict_with_still_available_choice AssertionError: 302 != 200 : Couldn't retrieve content: Response code was 302 (expected 200)

Check failure on line 608 in weblate/trans/tests/test_edit.py

View workflow job for this annotation

GitHub Actions / py3.14, edge deps

ReviewStateTest.test_conflict_with_still_available_choice AssertionError: 302 != 200 : Couldn't retrieve content: Response code was 302 (expected 200)

Check failure on line 608 in weblate/trans/tests/test_edit.py

View workflow job for this annotation

GitHub Actions / py3.13, latest deps

ReviewStateTest.test_conflict_with_still_available_choice AssertionError: 302 != 200 : Couldn't retrieve content: Response code was 302 (expected 200)

Check failure on line 608 in weblate/trans/tests/test_edit.py

View workflow job for this annotation

GitHub Actions / macos

ReviewStateTest.test_conflict_with_still_available_choice AssertionError: 302 != 200 : Couldn't retrieve content: Response code was 302 (expected 200)
self.unit.refresh_from_db()
self.assertEqual(self.unit.state, STATE_NEEDS_CHECKING)

Expand Down Expand Up @@ -664,7 +671,7 @@
reverse("save_zen", kwargs=self.kw_translation), self.data
)
data = response.json()
self.assertEqual(data["state"], "danger")

Check failure on line 674 in weblate/trans/tests/test_edit.py

View workflow job for this annotation

GitHub Actions / py3.14, latest deps

ReviewStateTest.test_zen_state_conflict AssertionError: 'info' != 'danger' - info + danger

Check failure on line 674 in weblate/trans/tests/test_edit.py

View workflow job for this annotation

GitHub Actions / py3.12, latest deps

ReviewStateTest.test_zen_state_conflict AssertionError: 'info' != 'danger' - info + danger

Check failure on line 674 in weblate/trans/tests/test_edit.py

View workflow job for this annotation

GitHub Actions / py3.14, edge deps

ReviewStateTest.test_zen_state_conflict AssertionError: 'info' != 'danger' - info + danger

Check failure on line 674 in weblate/trans/tests/test_edit.py

View workflow job for this annotation

GitHub Actions / py3.13, latest deps

ReviewStateTest.test_zen_state_conflict AssertionError: 'info' != 'danger' - info + danger

Check failure on line 674 in weblate/trans/tests/test_edit.py

View workflow job for this annotation

GitHub Actions / macos

ReviewStateTest.test_zen_state_conflict AssertionError: 'info' != 'danger' - info + danger
self.assertEqual(data["translationsum"], "")
self.assertIsNone(data["initial_state"])
self.assertEqual(len(data["messages"]), 1)
Expand Down Expand Up @@ -1416,7 +1423,7 @@
)

# pylint: disable=arguments-differ
def edit_unit(self, source, target, language="cs", **kwargs):

Check failure on line 1426 in weblate/trans/tests/test_edit.py

View workflow job for this annotation

GitHub Actions / mypy

Signature of "edit_unit" incompatible with supertype "weblate.trans.tests.test_views.ComponentTestCase"
"""Do edit single unit using web interface."""
unit = self.get_unit(source, language)
params = {
Expand Down Expand Up @@ -3558,13 +3565,13 @@

self.assertEqual(
get_sort_name(
request, ProjectLanguage(self.project, self.translation.language)

Check failure on line 3568 in weblate/trans/tests/test_edit.py

View workflow job for this annotation

GitHub Actions / mypy

Argument 1 to "get_sort_name" has incompatible type "SimpleNamespace"; expected "AuthenticatedHttpRequest"
)["query"],
"component,-priority",
)
self.assertEqual(
get_sort_name(
request, CategoryLanguage(category, self.translation.language)

Check failure on line 3574 in weblate/trans/tests/test_edit.py

View workflow job for this annotation

GitHub Actions / mypy

Argument 1 to "get_sort_name" has incompatible type "SimpleNamespace"; expected "AuthenticatedHttpRequest"
)["query"],
"component,-priority",
)
Expand Down
Loading