We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Bad logo URL when creating a new Safe App
**Describe the bug**
When inserting a new Safe App, `None` is added to the logo image URL instead of the `app_id`. 

Re-uploading the image for the Safe App solves the problem.

**To Reproduce**
Steps to reproduce the behavior:
- Create a new Safe App.
- Check the path for the logo image is not correct (it includes `None` as ID).

**Expected behavior**
A correct Safe App `app_id` is added to the logo path instead of `None`.

**Environment (please complete the following information):**
 - Staging and production.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/safe_apps/models.py`
Content:
```
1 import os
2 from enum import Enum
3 from typing import IO, Union
4 
5 from django.contrib.postgres.fields import ArrayField
6 from django.core.exceptions import ValidationError
7 from django.core.files.images import get_image_dimensions
8 from django.core.validators import RegexValidator
9 from django.db import models
10 
11 _HOSTNAME_VALIDATOR = RegexValidator(
12     r"^(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\/?$",
13     message="Enter a valid hostname (Without a resource path)",
14     code="invalid_hostname",
15 )
16 
17 
18 def safe_app_icon_path(instance: "SafeApp", filename: str) -> str:
19     _, file_extension = os.path.splitext(filename)
20     return f"safe_apps/{instance.app_id}/icon{file_extension}"
21 
22 
23 def validate_safe_app_icon_size(image: Union[str, IO[bytes]]) -> None:
24     width, height = get_image_dimensions(image)
25     if not width or not height:
26         raise ValidationError(
27             f"Could not get image dimensions. Width={width}, Height={height}"
28         )
29     if width > 512 or height > 512:
30         raise ValidationError("Image width and height need to be at most 512 pixels")
31 
32 
33 class Provider(models.Model):
34     url = models.URLField(primary_key=True)
35     name = models.CharField(max_length=200)
36 
37     def __str__(self) -> str:
38         return f"{self.name} | {self.url}"
39 
40 
41 class Client(models.Model):
42     url = models.CharField(
43         unique=True,
44         help_text="The domain URL client is hosted at",
45         # The maximum length of a full host name is 253 characters per RFC 1034
46         max_length=255,
47         validators=[_HOSTNAME_VALIDATOR],
48     )
49 
50     def __str__(self) -> str:
51         return f"Client: {self.url}"
52 
53 
54 class SafeApp(models.Model):
55     class AccessControlPolicy(str, Enum):
56         NO_RESTRICTIONS = "NO_RESTRICTIONS"
57         DOMAIN_ALLOWLIST = "DOMAIN_ALLOWLIST"
58 
59     app_id = models.BigAutoField(primary_key=True)
60     visible = models.BooleanField(
61         default=True
62     )  # True if this safe-app should be visible from the view. False otherwise
63     url = models.URLField()
64     name = models.CharField(max_length=200)
65     icon_url = models.ImageField(
66         validators=[validate_safe_app_icon_size],
67         upload_to=safe_app_icon_path,
68         max_length=255,
69         null=True,
70         blank=True,
71     )
72     description = models.CharField(max_length=200)
73     chain_ids = ArrayField(models.PositiveBigIntegerField())
74     provider = models.ForeignKey(
75         Provider, null=True, blank=True, on_delete=models.SET_NULL
76     )
77     exclusive_clients = models.ManyToManyField(
78         Client,
79         blank=True,
80         help_text="Clients that are only allowed to use this SafeApp",
81     )
82     developer_website = models.URLField(null=True, blank=True)
83 
84     def get_access_control_type(self) -> AccessControlPolicy:
85         if self.exclusive_clients.exists():
86             return SafeApp.AccessControlPolicy.DOMAIN_ALLOWLIST
87         return SafeApp.AccessControlPolicy.NO_RESTRICTIONS
88 
89     def __str__(self) -> str:
90         return f"{self.name} | {self.url} | chain_ids={self.chain_ids}"
91 
92 
93 class Tag(models.Model):
94     name = models.CharField(max_length=255)
95     safe_apps = models.ManyToManyField(SafeApp, blank=True)
96 
97     def __str__(self) -> str:
98         return f"Tag: {self.name}"
99 
100 
101 class Feature(models.Model):
102     # A feature can be enabled for multiple Safe Apps and a Safe App can have multiple features enabled
103     safe_apps = models.ManyToManyField(
104         SafeApp, blank=True, help_text="Safe Apps where this feature is enabled."
105     )
106     key = models.CharField(
107         unique=True,
108         max_length=255,
109         help_text="The unique name/key that identifies this feature",
110     )
111 
112     def __str__(self) -> str:
113         return f"Safe App Feature: {self.key}"
114 
115 
116 class SocialProfile(models.Model):
117     class Platform(models.TextChoices):
118         DISCORD = "DISCORD"
119         GITHUB = "GITHUB"
120         TWITTER = "TWITTER"
121 
122     safe_app = models.ForeignKey(SafeApp, on_delete=models.CASCADE)
123     platform = models.CharField(choices=Platform.choices, max_length=255)
124     url = models.URLField()
125 
126     def __str__(self) -> str:
127         return f"Social Profile: {self.platform} | {self.url}"
128
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/safe_apps/models.py b/src/safe_apps/models.py
--- a/src/safe_apps/models.py
+++ b/src/safe_apps/models.py
@@ -1,4 +1,5 @@
 import os
+import uuid
 from enum import Enum
 from typing import IO, Union
 
@@ -17,7 +18,7 @@
 
 def safe_app_icon_path(instance: "SafeApp", filename: str) -> str:
     _, file_extension = os.path.splitext(filename)
-    return f"safe_apps/{instance.app_id}/icon{file_extension}"
+    return f"safe_apps/{uuid.uuid4()}/icon{file_extension}"
 
 
 def validate_safe_app_icon_size(image: Union[str, IO[bytes]]) -> None:

{"golden_diff": "diff --git a/src/safe_apps/models.py b/src/safe_apps/models.py\n--- a/src/safe_apps/models.py\n+++ b/src/safe_apps/models.py\n@@ -1,4 +1,5 @@\n import os\n+import uuid\n from enum import Enum\n from typing import IO, Union\n \n@@ -17,7 +18,7 @@\n \n def safe_app_icon_path(instance: \"SafeApp\", filename: str) -> str:\n     _, file_extension = os.path.splitext(filename)\n-    return f\"safe_apps/{instance.app_id}/icon{file_extension}\"\n+    return f\"safe_apps/{uuid.uuid4()}/icon{file_extension}\"\n \n \n def validate_safe_app_icon_size(image: Union[str, IO[bytes]]) -> None:\n", "issue": "Bad logo URL when creating a new Safe App\n**Describe the bug**\r\nWhen inserting a new Safe App, `None` is added to the logo image URL instead of the `app_id`. \r\n\r\nRe-uploading the image for the Safe App solves the problem.\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n- Create a new Safe App.\r\n- Check the path for the logo image is not correct (it includes `None` as ID).\r\n\r\n**Expected behavior**\r\nA correct Safe App `app_id` is added to the logo path instead of `None`.\r\n\r\n**Environment (please complete the following information):**\r\n - Staging and production.\r\n\n", "before_files": [{"content": "import os\nfrom enum import Enum\nfrom typing import IO, Union\n\nfrom django.contrib.postgres.fields import ArrayField\nfrom django.core.exceptions import ValidationError\nfrom django.core.files.images import get_image_dimensions\nfrom django.core.validators import RegexValidator\nfrom django.db import models\n\n_HOSTNAME_VALIDATOR = RegexValidator(\n    r\"^(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,6}\\/?$\",\n    message=\"Enter a valid hostname (Without a resource path)\",\n    code=\"invalid_hostname\",\n)\n\n\ndef safe_app_icon_path(instance: \"SafeApp\", filename: str) -> str:\n    _, file_extension = os.path.splitext(filename)\n    return f\"safe_apps/{instance.app_id}/icon{file_extension}\"\n\n\ndef validate_safe_app_icon_size(image: Union[str, IO[bytes]]) -> None:\n    width, height = get_image_dimensions(image)\n    if not width or not height:\n        raise ValidationError(\n            f\"Could not get image dimensions. Width={width}, Height={height}\"\n        )\n    if width > 512 or height > 512:\n        raise ValidationError(\"Image width and height need to be at most 512 pixels\")\n\n\nclass Provider(models.Model):\n    url = models.URLField(primary_key=True)\n    name = models.CharField(max_length=200)\n\n    def __str__(self) -> str:\n        return f\"{self.name} | {self.url}\"\n\n\nclass Client(models.Model):\n    url = models.CharField(\n        unique=True,\n        help_text=\"The domain URL client is hosted at\",\n        # The maximum length of a full host name is 253 characters per RFC 1034\n        max_length=255,\n        validators=[_HOSTNAME_VALIDATOR],\n    )\n\n    def __str__(self) -> str:\n        return f\"Client: {self.url}\"\n\n\nclass SafeApp(models.Model):\n    class AccessControlPolicy(str, Enum):\n        NO_RESTRICTIONS = \"NO_RESTRICTIONS\"\n        DOMAIN_ALLOWLIST = \"DOMAIN_ALLOWLIST\"\n\n    app_id = models.BigAutoField(primary_key=True)\n    visible = models.BooleanField(\n        default=True\n    )  # True if this safe-app should be visible from the view. False otherwise\n    url = models.URLField()\n    name = models.CharField(max_length=200)\n    icon_url = models.ImageField(\n        validators=[validate_safe_app_icon_size],\n        upload_to=safe_app_icon_path,\n        max_length=255,\n        null=True,\n        blank=True,\n    )\n    description = models.CharField(max_length=200)\n    chain_ids = ArrayField(models.PositiveBigIntegerField())\n    provider = models.ForeignKey(\n        Provider, null=True, blank=True, on_delete=models.SET_NULL\n    )\n    exclusive_clients = models.ManyToManyField(\n        Client,\n        blank=True,\n        help_text=\"Clients that are only allowed to use this SafeApp\",\n    )\n    developer_website = models.URLField(null=True, blank=True)\n\n    def get_access_control_type(self) -> AccessControlPolicy:\n        if self.exclusive_clients.exists():\n            return SafeApp.AccessControlPolicy.DOMAIN_ALLOWLIST\n        return SafeApp.AccessControlPolicy.NO_RESTRICTIONS\n\n    def __str__(self) -> str:\n        return f\"{self.name} | {self.url} | chain_ids={self.chain_ids}\"\n\n\nclass Tag(models.Model):\n    name = models.CharField(max_length=255)\n    safe_apps = models.ManyToManyField(SafeApp, blank=True)\n\n    def __str__(self) -> str:\n        return f\"Tag: {self.name}\"\n\n\nclass Feature(models.Model):\n    # A feature can be enabled for multiple Safe Apps and a Safe App can have multiple features enabled\n    safe_apps = models.ManyToManyField(\n        SafeApp, blank=True, help_text=\"Safe Apps where this feature is enabled.\"\n    )\n    key = models.CharField(\n        unique=True,\n        max_length=255,\n        help_text=\"The unique name/key that identifies this feature\",\n    )\n\n    def __str__(self) -> str:\n        return f\"Safe App Feature: {self.key}\"\n\n\nclass SocialProfile(models.Model):\n    class Platform(models.TextChoices):\n        DISCORD = \"DISCORD\"\n        GITHUB = \"GITHUB\"\n        TWITTER = \"TWITTER\"\n\n    safe_app = models.ForeignKey(SafeApp, on_delete=models.CASCADE)\n    platform = models.CharField(choices=Platform.choices, max_length=255)\n    url = models.URLField()\n\n    def __str__(self) -> str:\n        return f\"Social Profile: {self.platform} | {self.url}\"\n", "path": "src/safe_apps/models.py"}], "after_files": [{"content": "import os\nimport uuid\nfrom enum import Enum\nfrom typing import IO, Union\n\nfrom django.contrib.postgres.fields import ArrayField\nfrom django.core.exceptions import ValidationError\nfrom django.core.files.images import get_image_dimensions\nfrom django.core.validators import RegexValidator\nfrom django.db import models\n\n_HOSTNAME_VALIDATOR = RegexValidator(\n    r\"^(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,6}\\/?$\",\n    message=\"Enter a valid hostname (Without a resource path)\",\n    code=\"invalid_hostname\",\n)\n\n\ndef safe_app_icon_path(instance: \"SafeApp\", filename: str) -> str:\n    _, file_extension = os.path.splitext(filename)\n    return f\"safe_apps/{uuid.uuid4()}/icon{file_extension}\"\n\n\ndef validate_safe_app_icon_size(image: Union[str, IO[bytes]]) -> None:\n    width, height = get_image_dimensions(image)\n    if not width or not height:\n        raise ValidationError(\n            f\"Could not get image dimensions. Width={width}, Height={height}\"\n        )\n    if width > 512 or height > 512:\n        raise ValidationError(\"Image width and height need to be at most 512 pixels\")\n\n\nclass Provider(models.Model):\n    url = models.URLField(primary_key=True)\n    name = models.CharField(max_length=200)\n\n    def __str__(self) -> str:\n        return f\"{self.name} | {self.url}\"\n\n\nclass Client(models.Model):\n    url = models.CharField(\n        unique=True,\n        help_text=\"The domain URL client is hosted at\",\n        # The maximum length of a full host name is 253 characters per RFC 1034\n        max_length=255,\n        validators=[_HOSTNAME_VALIDATOR],\n    )\n\n    def __str__(self) -> str:\n        return f\"Client: {self.url}\"\n\n\nclass SafeApp(models.Model):\n    class AccessControlPolicy(str, Enum):\n        NO_RESTRICTIONS = \"NO_RESTRICTIONS\"\n        DOMAIN_ALLOWLIST = \"DOMAIN_ALLOWLIST\"\n\n    app_id = models.BigAutoField(primary_key=True)\n    visible = models.BooleanField(\n        default=True\n    )  # True if this safe-app should be visible from the view. False otherwise\n    url = models.URLField()\n    name = models.CharField(max_length=200)\n    icon_url = models.ImageField(\n        validators=[validate_safe_app_icon_size],\n        upload_to=safe_app_icon_path,\n        max_length=255,\n        null=True,\n        blank=True,\n    )\n    description = models.CharField(max_length=200)\n    chain_ids = ArrayField(models.PositiveBigIntegerField())\n    provider = models.ForeignKey(\n        Provider, null=True, blank=True, on_delete=models.SET_NULL\n    )\n    exclusive_clients = models.ManyToManyField(\n        Client,\n        blank=True,\n        help_text=\"Clients that are only allowed to use this SafeApp\",\n    )\n    developer_website = models.URLField(null=True, blank=True)\n\n    def get_access_control_type(self) -> AccessControlPolicy:\n        if self.exclusive_clients.exists():\n            return SafeApp.AccessControlPolicy.DOMAIN_ALLOWLIST\n        return SafeApp.AccessControlPolicy.NO_RESTRICTIONS\n\n    def __str__(self) -> str:\n        return f\"{self.name} | {self.url} | chain_ids={self.chain_ids}\"\n\n\nclass Tag(models.Model):\n    name = models.CharField(max_length=255)\n    safe_apps = models.ManyToManyField(SafeApp, blank=True)\n\n    def __str__(self) -> str:\n        return f\"Tag: {self.name}\"\n\n\nclass Feature(models.Model):\n    # A feature can be enabled for multiple Safe Apps and a Safe App can have multiple features enabled\n    safe_apps = models.ManyToManyField(\n        SafeApp, blank=True, help_text=\"Safe Apps where this feature is enabled.\"\n    )\n    key = models.CharField(\n        unique=True,\n        max_length=255,\n        help_text=\"The unique name/key that identifies this feature\",\n    )\n\n    def __str__(self) -> str:\n        return f\"Safe App Feature: {self.key}\"\n\n\nclass SocialProfile(models.Model):\n    class Platform(models.TextChoices):\n        DISCORD = \"DISCORD\"\n        GITHUB = \"GITHUB\"\n        TWITTER = \"TWITTER\"\n\n    safe_app = models.ForeignKey(SafeApp, on_delete=models.CASCADE)\n    platform = models.CharField(choices=Platform.choices, max_length=255)\n    url = models.URLField()\n\n    def __str__(self) -> str:\n        return f\"Social Profile: {self.platform} | {self.url}\"\n", "path": "src/safe_apps/models.py"}]}