We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Don't crash when a nomcom is partially set up.
Right now, if a nomcom group is created, and the associated NomCom object is not, anyone with a role in the nomcom group cannot use the datatracker - the construction of the menu crashes.

The places that crash need to be protected against this misconfiguration (especially while the configuration of the Group and NomCom objects are done manually).

See also https://github.com/ietf-tools/datatracker/issues/3289

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `ietf/group/templatetags/group_filters.py`
Content:
```
1 from django import template
2 
3 import debug                            # pyflakes:ignore
4 
5 from ietf.group.models import Group
6 
7 register = template.Library()
8 
9 @register.filter
10 def has_sessions(group,num):
11     return group.session_set.filter(meeting__number=num).exists()
12 
13 @register.filter
14 def active_roles(queryset):
15     return queryset.filter(group__state_id__in=['active', 'bof']).exclude(group__acronym='secretariat')
16     
17 @register.filter
18 def active_nomcoms(user):
19     if not (user and hasattr(user, "is_authenticated") and user.is_authenticated):
20         return []
21 
22     groups = []
23 
24     groups.extend(Group.objects.filter(
25         role__person__user=user,
26         type_id='nomcom',
27         state__slug='active').distinct().select_related("type"))
28 
29     return groups
30 
31 @register.inclusion_tag('person/person_link.html')
32 def role_person_link(role, **kwargs):
33     title = kwargs.get('title', '')
34     cls = kwargs.get('class', '')
35     name = role.person.name
36     plain_name = role.person.plain_name()
37     email = role.email.address
38     return {'name': name, 'plain_name': plain_name, 'email': email, 'title': title, 'class': cls}
39
```
--- 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/ietf/group/templatetags/group_filters.py b/ietf/group/templatetags/group_filters.py
--- a/ietf/group/templatetags/group_filters.py
+++ b/ietf/group/templatetags/group_filters.py
@@ -2,7 +2,7 @@
 
 import debug                            # pyflakes:ignore
 
-from ietf.group.models import Group
+from ietf.nomcom.models import NomCom
 
 register = template.Library()
 
@@ -19,14 +19,15 @@
     if not (user and hasattr(user, "is_authenticated") and user.is_authenticated):
         return []
 
-    groups = []
-
-    groups.extend(Group.objects.filter(
-        role__person__user=user,
-        type_id='nomcom',
-        state__slug='active').distinct().select_related("type"))
-
-    return groups
+    return list(
+        NomCom.objects.filter(
+            group__role__person__user=user,
+            group__type_id='nomcom',  # just in case...
+            group__state__slug='active',
+        )
+        .distinct()
+        .order_by("group__acronym")
+    )
 
 @register.inclusion_tag('person/person_link.html')
 def role_person_link(role, **kwargs):

{"golden_diff": "diff --git a/ietf/group/templatetags/group_filters.py b/ietf/group/templatetags/group_filters.py\n--- a/ietf/group/templatetags/group_filters.py\n+++ b/ietf/group/templatetags/group_filters.py\n@@ -2,7 +2,7 @@\n \n import debug                            # pyflakes:ignore\n \n-from ietf.group.models import Group\n+from ietf.nomcom.models import NomCom\n \n register = template.Library()\n \n@@ -19,14 +19,15 @@\n     if not (user and hasattr(user, \"is_authenticated\") and user.is_authenticated):\n         return []\n \n-    groups = []\n-\n-    groups.extend(Group.objects.filter(\n-        role__person__user=user,\n-        type_id='nomcom',\n-        state__slug='active').distinct().select_related(\"type\"))\n-\n-    return groups\n+    return list(\n+        NomCom.objects.filter(\n+            group__role__person__user=user,\n+            group__type_id='nomcom',  # just in case...\n+            group__state__slug='active',\n+        )\n+        .distinct()\n+        .order_by(\"group__acronym\")\n+    )\n \n @register.inclusion_tag('person/person_link.html')\n def role_person_link(role, **kwargs):\n", "issue": "Don't crash when a nomcom is partially set up.\nRight now, if a nomcom group is created, and the associated NomCom object is not, anyone with a role in the nomcom group cannot use the datatracker - the construction of the menu crashes.\r\n\r\nThe places that crash need to be protected against this misconfiguration (especially while the configuration of the Group and NomCom objects are done manually).\r\n\r\nSee also https://github.com/ietf-tools/datatracker/issues/3289\n", "before_files": [{"content": "from django import template\n\nimport debug                            # pyflakes:ignore\n\nfrom ietf.group.models import Group\n\nregister = template.Library()\n\n@register.filter\ndef has_sessions(group,num):\n    return group.session_set.filter(meeting__number=num).exists()\n\n@register.filter\ndef active_roles(queryset):\n    return queryset.filter(group__state_id__in=['active', 'bof']).exclude(group__acronym='secretariat')\n    \n@register.filter\ndef active_nomcoms(user):\n    if not (user and hasattr(user, \"is_authenticated\") and user.is_authenticated):\n        return []\n\n    groups = []\n\n    groups.extend(Group.objects.filter(\n        role__person__user=user,\n        type_id='nomcom',\n        state__slug='active').distinct().select_related(\"type\"))\n\n    return groups\n\n@register.inclusion_tag('person/person_link.html')\ndef role_person_link(role, **kwargs):\n    title = kwargs.get('title', '')\n    cls = kwargs.get('class', '')\n    name = role.person.name\n    plain_name = role.person.plain_name()\n    email = role.email.address\n    return {'name': name, 'plain_name': plain_name, 'email': email, 'title': title, 'class': cls}\n", "path": "ietf/group/templatetags/group_filters.py"}], "after_files": [{"content": "from django import template\n\nimport debug                            # pyflakes:ignore\n\nfrom ietf.nomcom.models import NomCom\n\nregister = template.Library()\n\n@register.filter\ndef has_sessions(group,num):\n    return group.session_set.filter(meeting__number=num).exists()\n\n@register.filter\ndef active_roles(queryset):\n    return queryset.filter(group__state_id__in=['active', 'bof']).exclude(group__acronym='secretariat')\n    \n@register.filter\ndef active_nomcoms(user):\n    if not (user and hasattr(user, \"is_authenticated\") and user.is_authenticated):\n        return []\n\n    return list(\n        NomCom.objects.filter(\n            group__role__person__user=user,\n            group__type_id='nomcom',  # just in case...\n            group__state__slug='active',\n        )\n        .distinct()\n        .order_by(\"group__acronym\")\n    )\n\n@register.inclusion_tag('person/person_link.html')\ndef role_person_link(role, **kwargs):\n    title = kwargs.get('title', '')\n    cls = kwargs.get('class', '')\n    name = role.person.name\n    plain_name = role.person.plain_name()\n    email = role.email.address\n    return {'name': name, 'plain_name': plain_name, 'email': email, 'title': title, 'class': cls}\n", "path": "ietf/group/templatetags/group_filters.py"}]}