Repository: WeblateOrg/weblate

Issue:
Backup does not restore
### Describe the issue

I am trying to import a backup from a project exported on another Weblate instance. This is not successful and yields the following cryptic error message:

>Failed to load project backup: '' is too short Failed validating 'minLength' in schema['items']['properties']['source']: {'$id': '#/items/properties/source', 'default': '', 'examples': ['Hello'], 'minLength': 1, 'title': 'The Source String', 'type': 'string'} On instance[81]['source']: ''

Unfortunately I do not understand what this means and failed to find and fix the problem in my backup ZIP manually.

Both instances are running the same weblate version. Two other projects have successfully exported and imported in this combination of instances.

### I already tried

- [X] I've read and searched [the documentation](https://docs.weblate.org/).
- [X] I've searched for similar issues in this repository.

### Steps to reproduce the behavior

- Add new translation project → Import backup
- Upload my project backup as exported from https://weblate.bubu1.eu/projects/librariesdirect/librariesdirect/: [1678372565.zip](https://github.com/WeblateOrg/weblate/files/10932734/1678372565.zip)


### Expected behavior

The backup should import successfully.

### Screenshots

_No response_

### Exception traceback

_No response_

### How do you run Weblate?

Docker

### Weblate versions

Both instances run 4.16.2

### Weblate deploy checks

_No response_

### Additional context

_No response_


Discussion:
The problem is that there is an empty string in the translation memory (inside `weblate-memory.json`):

```json
  {
    "source": "",
    "target": " ",
    "source_language": "en",
    "target_language": "pt_BR",
    "origin": "librariesdirect/librariesdirect",
    "category": 10000003
  }
```

Removing it should fix the import. 

Still, Weblate should handle this gracefully.
Thanks, I've removed the faulty entry from my JSON file and the import was now successful.

Resolving patch:
diff --git a/weblate/memory/migrations/0015_remove_blank.py b/weblate/memory/migrations/0015_remove_blank.py
new file mode 100644
--- /dev/null
+++ b/weblate/memory/migrations/0015_remove_blank.py
@@ -0,0 +1,20 @@
+# Copyright © Michal Čihař <michal@weblate.org>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# Generated by Django 4.1.7 on 2023-03-14 11:28
+
+from django.db import migrations
+
+
+def remove_blank(apps, schema_editor):
+    Memory = apps.get_model("memory", "Memory")
+    Memory.objects.using(schema_editor.connection.alias).filter(source="").delete()
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("memory", "0014_rename_index"),
+    ]
+
+    operations = [migrations.RunPython(remove_blank, elidable=True)]
diff --git a/weblate/trans/models/unit.py b/weblate/trans/models/unit.py
--- a/weblate/trans/models/unit.py
+++ b/weblate/trans/models/unit.py
@@ -1361,7 +1361,8 @@ def translate(
         if (
             user
             and self.target != self.old_unit["target"]
-            and self.target
+            and any(self.get_target_plurals())
+            and any(self.get_source_plurals())
             and self.state >= STATE_TRANSLATED
             and not component.is_glossary
         ):


Test patch: