Repository: oppia/oppia

Issue:
[Topic Editor] Saving topic without change description results in error
<!--
  - Thanks for taking the time to report a bug in the Oppia project.
  - Before filing a new issue, please do a quick search to check that it hasn't
  - already been filed on the [issue tracker](https://github.com/oppia/oppia/issues)._
  -->

**Describe the bug**
If a user saves a topic without entering a description in the save draft modal then it results in an error.

**Observed behavior**
Displays an ambiguous error.

**Expected behavior**
Possible solutions

1. Clear message error
2. Do not let users save unless description is filled
3. Let users save with empty descriptions.

**Screenshots**

https://user-images.githubusercontent.com/30050862/136396221-fc515cd7-5311-48e6-b2ed-738ea0fc1f7f.mp4

**Desktop (please complete the following information; delete this section if the issue does not arise on desktop):**
 - OS: ubunut 20.04
 - Browser Chrome
 - Browser-version 94.0.4606.71

[Topic Editor] Saving topic without change description results in error
<!--
  - Thanks for taking the time to report a bug in the Oppia project.
  - Before filing a new issue, please do a quick search to check that it hasn't
  - already been filed on the [issue tracker](https://github.com/oppia/oppia/issues)._
  -->

**Describe the bug**
If a user saves a topic without entering a description in the save draft modal then it results in an error.

**Observed behavior**
Displays an ambiguous error.

**Expected behavior**
Possible solutions

1. Clear message error
2. Do not let users save unless description is filled
3. Let users save with empty descriptions.

**Screenshots**

https://user-images.githubusercontent.com/30050862/136396221-fc515cd7-5311-48e6-b2ed-738ea0fc1f7f.mp4

**Desktop (please complete the following information; delete this section if the issue does not arise on desktop):**
 - OS: ubunut 20.04
 - Browser Chrome
 - Browser-version 94.0.4606.71



Discussion:
Can I work on this issue?
Can I work on this issue?

Resolving patch:
diff --git a/core/domain/topic_services.py b/core/domain/topic_services.py
--- a/core/domain/topic_services.py
+++ b/core/domain/topic_services.py
@@ -435,7 +435,8 @@ def update_topic_and_subtopic_pages(
     Raises:
         ValueError. Current user does not have enough rights to edit a topic.
     """
-    if not commit_message:
+    topic_rights = topic_fetchers.get_topic_rights(topic_id, strict=False)
+    if topic_rights.topic_is_published and not commit_message:
         raise ValueError(
             'Expected a commit message, received none.')
 


Test patch:
diff --git a/core/domain/topic_services_test.py b/core/domain/topic_services_test.py
--- a/core/domain/topic_services_test.py
+++ b/core/domain/topic_services_test.py
@@ -1539,6 +1539,18 @@ def test_cannot_update_topic_and_subtopic_pages_with_mismatch_of_versions(
 
     def test_cannot_update_topic_and_subtopic_pages_with_empty_commit_message(
             self):
+        changelist = [topic_domain.TopicChange({
+            'cmd': topic_domain.CMD_MOVE_SKILL_ID_TO_SUBTOPIC,
+            'old_subtopic_id': None,
+            'new_subtopic_id': self.subtopic_id,
+            'skill_id': 'skill_1'
+        })]
+        # Test can have an empty commit message when not published.
+        topic_services.update_topic_and_subtopic_pages(
+            self.user_id_admin, self.TOPIC_ID, changelist,
+            None)
+        topic_services.publish_topic(self.TOPIC_ID, self.user_id_admin)
+        # Test must have a commit message when published.
         with self.assertRaisesRegexp(
             Exception, 'Expected a commit message, received none.'):
             topic_services.update_topic_and_subtopic_pages(