internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: ietf-tools/datatracker

Issue:
Datatracker Searches No Longer Return RFCs for WG document Searches
### Describe the issue

rom: 	"Acee Lindem" <acee.lindem@gmail.com>
Date: 	Thu, 14 Dec 2023 18:57:48 -0500
To: 	"IETF Support via RT" <support@ietf.org>
Subject: 	Datatracker Searches No Longer Return RFCs for WG document Searches

When searching in the datatracker (i.e., https://datatracker.ietf.org/) for “ietf-lsr-“ or “ietf-ospf”, the RFCs that were previously returned are no longer returned in the search results. Only the active WG documents are returned even if RFC is checked in the “Search criteria”.

Thanks,
Acee

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:

Resolving patch:
diff --git a/ietf/doc/views_search.py b/ietf/doc/views_search.py
--- a/ietf/doc/views_search.py
+++ b/ietf/doc/views_search.py
@@ -211,6 +211,9 @@ def retrieve_search_results(form, all_types=False):
                     Q(targets_related__source__title__icontains=singlespace, targets_related__relationship_id="contains"),
                 ])
 
+        if query["rfcs"]:
+            queries.extend([Q(targets_related__source__name__icontains=look_for, targets_related__relationship_id="became_rfc")])
+
         combined_query = reduce(operator.or_, queries)
         docs = docs.filter(combined_query).distinct()
 


Test patch:
diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py
--- a/ietf/doc/tests.py
+++ b/ietf/doc/tests.py
@@ -1,4 +1,4 @@
-# Copyright The IETF Trust 2012-2020, All Rights Reserved
+# Copyright The IETF Trust 2012-2023, All Rights Reserved
 # -*- coding: utf-8 -*-
 
 
@@ -156,6 +156,23 @@ def test_search(self):
         self.assertEqual(r.status_code, 200)
         self.assertContains(r, draft.title)
 
+    def test_search_became_rfc(self):
+        draft = WgDraftFactory()
+        rfc = WgRfcFactory()
+        draft.set_state(State.objects.get(type="draft", slug="rfc"))
+        draft.relateddocument_set.create(relationship_id="became_rfc", target=rfc)
+        base_url = urlreverse('ietf.doc.views_search.search')
+
+        # find by RFC
+        r = self.client.get(base_url + f"?rfcs=on&name={rfc.name}")
+        self.assertEqual(r.status_code, 200)
+        self.assertContains(r, rfc.title)
+
+        # find by draft
+        r = self.client.get(base_url + f"?activedrafts=on&rfcs=on&name={draft.name}")
+        self.assertEqual(r.status_code, 200)
+        self.assertContains(r, rfc.title)
+
     def test_search_for_name(self):
         draft = WgDraftFactory(name='draft-ietf-mars-test',group=GroupFactory(acronym='mars',parent=Group.objects.get(acronym='farfut')),authors=[PersonFactory()],ad=PersonFactory())
         draft.set_state(State.objects.get(used=True, type="draft-iesg", slug="pub-req"))
Repository: ietf-tools/datatracker

Issue:
AttributeError at /doc/draft-ietf-rreq-iprouters-require/idnits2-state/
### Describe the issue

After deployment of v12.0.0, getting a 500 error: `'NoneType' object has no attribute 'time'` at /doc/draft-ietf-rreq-iprouters-require/idnits2-state/

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:

Resolving patch:
diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py
--- a/ietf/doc/views_doc.py
+++ b/ietf/doc/views_doc.py
@@ -2185,13 +2185,31 @@ def idnits2_state(request, name, rev=None):
     if doc.type_id == "rfc":
         draft = doc.came_from_draft()
         if draft:
-            zero_revision = NewRevisionDocEvent.objects.filter(doc=draft,rev='00').first()
+            zero_revision = NewRevisionDocEvent.objects.filter(
+                doc=draft, rev="00"
+            ).first()
     else:
-        zero_revision = NewRevisionDocEvent.objects.filter(doc=doc,rev='00').first()
+        zero_revision = NewRevisionDocEvent.objects.filter(doc=doc, rev="00").first()
     if zero_revision:
         doc.created = zero_revision.time
     else:
-        doc.created = doc.docevent_set.order_by('-time').first().time
+        if doc.type_id == "draft":
+            if doc.became_rfc():
+                interesting_event = (
+                    doc.became_rfc()
+                    .docevent_set.filter(type="published_rfc")
+                    .order_by("-time")
+                    .first()
+                )
+            else:
+                interesting_event = doc.docevent_set.order_by(
+                    "-time"
+                ).first()  # Is taking the most _recent_ instead of the oldest event correct?
+        else:  # doc.type_id == "rfc"
+            interesting_event = (
+                doc.docevent_set.filter(type="published_rfc").order_by("-time").first()
+            )
+        doc.created = interesting_event.time
     if doc.std_level:
         doc.deststatus = doc.std_level.name
     elif doc.intended_std_level:
@@ -2199,8 +2217,16 @@ def idnits2_state(request, name, rev=None):
     else:
         text = doc.text()
         if text:
-            parsed_draft = PlaintextDraft(text=doc.text(), source=name, name_from_source=False)
+            parsed_draft = PlaintextDraft(
+                text=doc.text(), source=name, name_from_source=False
+            )
             doc.deststatus = parsed_draft.get_status()
         else:
-            doc.deststatus="Unknown"
-    return render(request, 'doc/idnits2-state.txt', context={'doc':doc}, content_type='text/plain;charset=utf-8')    
+            doc.deststatus = "Unknown"
+    return render(
+        request,
+        "doc/idnits2-state.txt",
+        context={"doc": doc},
+        content_type="text/plain;charset=utf-8",
+    )
+


Test patch:
Repository: ietf-tools/datatracker

Issue:
RFC column empty
### Describe the issue

The RFC column on https://datatracker.ietf.org/doc/ad/#rfc is empty.

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:
The graphs rewrite the element incorrectly if the input values are all zero. Consider tracking a separate issue to fix that unintended effect?

If you logout (and see the table with no graphs) the column is full of zeros (which I'll work to correct for this issue).
The issue with the column values is that the published_rfc event moved to the RFC document - it will never appear on a draft document. 

https://github.com/ietf-tools/datatracker/blob/50aa3995ee2f166ba90bf2fc00fef438d3243946/ietf/doc/views_search.py#L470-L474

Resolving patch:
diff --git a/ietf/doc/views_search.py b/ietf/doc/views_search.py
--- a/ietf/doc/views_search.py
+++ b/ietf/doc/views_search.py
@@ -468,11 +468,11 @@ def ad_workload(request):
             state = doc_state(doc)
 
             state_events = doc.docevent_set.filter(
-                Q(type="started_iesg_process")
-                | Q(type="changed_state")
-                | Q(type="published_rfc")
-                | Q(type="closed_ballot"),
-            ).order_by("-time")
+                type__in=["started_iesg_process", "changed_state", "closed_ballot"]
+            )
+            if doc.became_rfc():
+                state_events = state_events | doc.became_rfc().docevent_set.filter(type="published_rfc")
+            state_events = state_events.order_by("-time")
 
             # compute state history for drafts
             last = now


Test patch:
Repository: ietf-tools/datatracker

Issue:
the "Mailing list discussion" link for rfcs is incorrect
The generated link into the mailarchive uses `&q=` where it should use `/q=`. The query should also look for both references to the rfc name and the name of the draft the rfc came from.


Discussion:
Just a comment of no particular significance.  I realize it's your namespace, but is that meant to be a query, but yet doesn't quite look like one?  Would it make sense to add &q= into the mailarchive?
I think it's currently generating `.../?email_list=<acro>?q=<docname>` but should be`.../?email_list=<acro>&q=<docname>`
(i.e., what @elear asks for seems to be supported by mailarchive)
This is a data cleaning / code robustness issue:
https://github.com/ietf-tools/datatracker/blob/50aa3995ee2f166ba90bf2fc00fef438d3243946/ietf/templates/doc/document_info.html#L434
and
```
>>> Group.objects.filter(list_archive__endswith="/").count()
383
>>> Group.objects.exclude(list_archive="").exclude(list_archive__endswith="/").count()
334
```
And I typo-ed in the original post, stimulating an unnecessary conversation - apologies.
Yet redirects at mailarchive are handling those differences already. Attempting to rediscover the document that motivated this issue.
Relocated - the issue is at /doc/rfc5280/ which links to `https://mailarchive.ietf.org/arch/search/?email_list=pkix?q=rfc5280` because
```
>>> Group.objects.get(acronym='pkix').list_archive
'https://mailarchive.ietf.org/arch/search/?email_list=pkix'
```

Further:
```
>>> Group.objects.filter(list_archive__contains="?email_list").count()
165
```

We should transform those to use the shorter version of `/arch/browse/<acronym>`


Resolving patch:
diff --git a/ietf/group/migrations/0004_modern_list_archive.py b/ietf/group/migrations/0004_modern_list_archive.py
new file mode 100644
--- /dev/null
+++ b/ietf/group/migrations/0004_modern_list_archive.py
@@ -0,0 +1,24 @@
+# Copyright The IETF Trust 2023, All Rights Reserved
+
+from django.conf import settings
+from django.db import migrations
+from django.db.models import Value
+from django.db.models.functions import Replace
+
+
+def forward(apps, schema_editor):
+    Group = apps.get_model("group", "Group")
+    old_pattern = f"{settings.MAILING_LIST_ARCHIVE_URL}/arch/search/?email_list="
+    new_pattern = f"{settings.MAILING_LIST_ARCHIVE_URL}/arch/browse/"
+
+    Group.objects.filter(list_archive__startswith=old_pattern).update(
+        list_archive=Replace("list_archive", Value(old_pattern), Value(new_pattern))
+    )
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("group", "0003_iabworkshops"),
+    ]
+
+    operations = [migrations.RunPython(forward)]


Test patch:
Repository: ietf-tools/datatracker

Issue:
/doc/help/state/draft-stream-editorial/ fails with a 404
The page is looking for a state it cannot find.


Discussion:
The /doc/help/states view is not very helpful, and is inconsistently curated. We should really consider removing it or replacing it with something that is more informative.

Resolving patch:
diff --git a/ietf/doc/views_help.py b/ietf/doc/views_help.py
--- a/ietf/doc/views_help.py
+++ b/ietf/doc/views_help.py
@@ -1,5 +1,7 @@
 # Copyright The IETF Trust 2013-2023, All Rights Reserved
 
+import debug # pyflakes: ignore
+
 from django.shortcuts import render, get_object_or_404
 from django.http import Http404
 
@@ -18,6 +20,7 @@ def state_help(request, type=None):
         "draft-stream-irtf": ("draft-stream-irtf", "IRTF Stream States for Internet-Drafts"),
         "draft-stream-ise": ("draft-stream-ise", "ISE Stream States for Internet-Drafts"),
         "draft-stream-iab": ("draft-stream-iab", "IAB Stream States for Internet-Drafts"),
+        "draft-stream-editorial": ("draft-stream-editorial", "Editorial Stream States for Internet-Drafts"),
         "charter": ("charter", "Charter States"),
         "conflict-review": ("conflrev", "Conflict Review States"),
         "status-change": ("statchg", "RFC Status Change States"),


Test patch:
Repository: ietf-tools/datatracker

Issue:
ad dashboard shows drafts that have become RFCs both as drafts and as RFCs
See the sections labelled "RFCs" and "Published RFCs" - Only the second section should be kept.
At the moment, the sections don't have the same number of documents in them which is surprising. Develop and understanding of that while working on the issue.

Marking this major because it is causing Roman's dashboard to go over the search result size limit.


Discussion:
cc: @rdanyliw 
This was two issues interacting to make confusing results.
1) Filtering documents out of the interesting set of Documents with ad=this_ad happens _after_ the queryset has been limited to a maximum number
2) That filtering didn't remove drafts that had become RFCs (as it should post feat/rfc).

This is why there were both RFC Internet Drafts (`{state} {type}s`) and Published RFCs (again `{state} {type}s`) in the results, _and_ why the number of such things were different. In Roman's case some of the RFC Internet Drafts were in the fetched set after the cutoff.

This is another example of where prepare_document_table and fill_in_document_table_attributes have become far to convoluted and need to be redesigned.

Resolving patch:
diff --git a/ietf/doc/views_search.py b/ietf/doc/views_search.py
--- a/ietf/doc/views_search.py
+++ b/ietf/doc/views_search.py
@@ -591,7 +591,7 @@ def sort_key(doc):
     if not ad:
         raise Http404
 
-    results, meta = prepare_document_table(request, Document.objects.filter(ad=ad))
+    results, meta = prepare_document_table(request, Document.objects.filter(ad=ad), max_results=500)
     results.sort(key=lambda d: sort_key(d))
     del meta["headers"][-1]
 
@@ -611,6 +611,7 @@ def sort_key(doc):
             and (
                 r.get_state_slug("draft-iesg") == "dead"
                 or r.get_state_slug("draft") == "repl"
+                or r.get_state_slug("draft") == "rfc"
             )
         )
     ]


Test patch:
Repository: ietf-tools/datatracker

Issue:
the ietf meeting parts of upcoming.ics end a day early
Our custom ics should take into account (from RFC5545)

>The "DTEND" property
      for a "VEVENT" calendar component specifies the non-inclusive end
      of the event.

See 
https://github.com/ietf-tools/datatracker/blob/287cf0fe46c0b1b7548389b4327854567e6b29f8/ietf/templates/meeting/upcoming.ics#L28


Discussion:

Resolving patch:
diff --git a/ietf/doc/templatetags/ietf_filters.py b/ietf/doc/templatetags/ietf_filters.py
--- a/ietf/doc/templatetags/ietf_filters.py
+++ b/ietf/doc/templatetags/ietf_filters.py
@@ -539,6 +539,10 @@ def ics_date_time(dt, tzname):
         return f':{timestamp}Z'
     else:
         return f';TZID={ics_esc(tzname)}:{timestamp}'
+    
+@register.filter
+def next_day(value):
+    return value + datetime.timedelta(days=1)
 
 
 @register.filter


Test patch:
Repository: ietf-tools/datatracker

Issue:
Rework the search button in the action button row for a document page to not link to external search engines
Change
![image](https://github.com/ietf-tools/datatracker/assets/10996692/cfad9990-6504-4748-a3f0-f1d564113871)
to a simple button that searches the mailarchive only.


Discussion:
In the process, I believe this will become dead code:

https://github.com/ietf-tools/datatracker/blob/4c7be64e961fe97834f7170c01d6730d07c4adcb/ietf/doc/views_doc.py#L480

If I'm correct, please clean it away.
> Change
> ![image](https://github.com/ietf-tools/datatracker/assets/10996692/cfad9990-6504-4748-a3f0-f1d564113871)
> to a simple button that searches the mailarchive only.



Resolving patch:
diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py
--- a/ietf/doc/views_doc.py
+++ b/ietf/doc/views_doc.py
@@ -1,4 +1,4 @@
-# Copyright The IETF Trust 2009-2023, All Rights Reserved
+# Copyright The IETF Trust 2009-2024, All Rights Reserved
 # -*- coding: utf-8 -*-
 #
 # Parts Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
@@ -40,7 +40,6 @@
 import os
 import re
 
-from urllib.parse import quote
 from pathlib import Path
 
 from django.http import HttpResponse, Http404
@@ -480,13 +479,6 @@ def document_main(request, name, rev=None, document_html=False):
             can_submit_unsolicited_review_for_teams = Group.objects.filter(
                 reviewteamsettings__isnull=False, role__person__user=request.user, role__name='secr')
 
-        # mailing list search archive
-        search_archive = "www.ietf.org/mail-archive/web/"
-        if doc.stream_id == "ietf" and group.type_id == "wg" and group.list_archive:
-            search_archive = group.list_archive
-
-        search_archive = quote(search_archive, safe="~")
-
         # conflict reviews
         conflict_reviews = [r.source.name for r in interesting_relations_that.filter(relationship="conflrev")]
 
@@ -705,7 +697,6 @@ def document_main(request, name, rev=None, document_html=False):
                                        iana_experts_comment=iana_experts_comment,
                                        started_iesg_process=started_iesg_process,
                                        shepherd_writeup=shepherd_writeup,
-                                       search_archive=search_archive,
                                        actions=actions,
                                        presentations=presentations,
                                        review_assignments=review_assignments,


Test patch:
Repository: ietf-tools/datatracker

Issue:
In review request when changing deadline etc no history line is generated
### Describe the issue

When changing them it should save simple history entry with description saying it changed those fields.

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:

Resolving patch:
diff --git a/ietf/doc/views_review.py b/ietf/doc/views_review.py
--- a/ietf/doc/views_review.py
+++ b/ietf/doc/views_review.py
@@ -1053,7 +1053,11 @@ def edit_deadline(request, name, request_id):
         if form.is_valid():
             if form.cleaned_data['deadline'] != old_deadline:
                 form.save()
-                subject = "Deadline changed: {} {} review of {}-{}".format(review_req.team.acronym.capitalize(),review_req.type.name.lower(), review_req.doc.name, review_req.requested_rev)
+                subject = f"Deadline changed: {review_req.team.acronym.capitalize()} {review_req.type.name.lower()} review of {review_req.doc.name}"
+                if review_req.requested_rev:
+                    subject += f"-{review_req.requested_rev}"
+                descr = "Deadine changed from {} to {}".format(old_deadline, review_req.deadline)
+                update_change_reason(review_req, descr)
                 msg = render_to_string("review/deadline_changed.txt", {
                     "review_req": review_req,
                     "old_deadline": old_deadline,


Test patch:
Repository: ietf-tools/datatracker

Issue:
Missing button text for PostScript
### Describe the issue

Icon and button text are missing for the PostScript file downloads.
Examples:
* https://datatracker.ietf.org/doc/draft-ietf-tsvwg-quickstart/07/
* https://datatracker.ietf.org/doc/draft-ietf-rmt-bb-webrc/04/

Screenshot:
<img width="1183" alt="Screenshot 2024-01-09 at 17 38 22" src="https://github.com/ietf-tools/datatracker/assets/1027692/bb74989e-dac5-473f-bf29-623ca2d1d878">


### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:

Resolving patch:
diff --git a/ietf/doc/utils.py b/ietf/doc/utils.py
--- a/ietf/doc/utils.py
+++ b/ietf/doc/utils.py
@@ -1062,6 +1062,8 @@ def build_file_urls(doc: Union[Document, DocHistory]):
         base = settings.IETF_ID_ARCHIVE_URL
         file_urls = []
         for t in found_types:
+            if t == "ps": # Postscript might have been submitted but should not be displayed in the list of URLs
+                continue
             label = "plain text" if t == "txt" else t
             file_urls.append((label, base + doc.name + "-" + doc.rev + "." + t))
 


Test patch:
Repository: ietf-tools/datatracker

Issue:
development instances attempt to POST to the production rfc-editor when a stream manager requests publication
In development this POST should be bypassed and assumed to have succeeded instead.
Development instances don't have the right secrets available to allow the POST to succeed so until this is fixed, the only issue is the nuisance traffic that will get 401'ed.


Discussion:

Resolving patch:
diff --git a/ietf/sync/rfceditor.py b/ietf/sync/rfceditor.py
--- a/ietf/sync/rfceditor.py
+++ b/ietf/sync/rfceditor.py
@@ -802,6 +802,10 @@ def post_approved_draft(url, name):
     the data from the Datatracker and start processing it. Returns
     response and error (empty string if no error)."""
 
+    if settings.SERVER_MODE != "production":
+        log(f"In production, would have posted RFC-Editor notification of approved I-D '{name}' to '{url}'")
+        return "", ""
+
     # HTTP basic auth
     username = "dtracksync"
     password = settings.RFC_EDITOR_SYNC_PASSWORD


Test patch:
diff --git a/ietf/sync/tests.py b/ietf/sync/tests.py
--- a/ietf/sync/tests.py
+++ b/ietf/sync/tests.py
@@ -597,6 +597,29 @@ def test_update_draft_auth48_url(self):
         auth48_docurl = draft.documenturl_set.filter(tag_id='auth48').first()
         self.assertIsNone(auth48_docurl)
 
+    def test_post_approved_draft_in_production_only(self):
+        self.requests_mock.post("https://rfceditor.example.com/", status_code=200, text="OK")
+
+        # be careful playing with SERVER_MODE!
+        with override_settings(SERVER_MODE="test"):
+            self.assertEqual(
+                rfceditor.post_approved_draft("https://rfceditor.example.com/", "some-draft"),
+                ("", "")
+            )
+            self.assertFalse(self.requests_mock.called)
+        with override_settings(SERVER_MODE="development"):
+            self.assertEqual(
+                rfceditor.post_approved_draft("https://rfceditor.example.com/", "some-draft"),
+                ("", "")
+            )
+            self.assertFalse(self.requests_mock.called)
+        with override_settings(SERVER_MODE="production"):
+            self.assertEqual(
+                rfceditor.post_approved_draft("https://rfceditor.example.com/", "some-draft"),
+                ("", "")
+            )
+            self.assertTrue(self.requests_mock.called)
+
 
 class DiscrepanciesTests(TestCase):
     def test_discrepancies(self):
@@ -636,6 +659,7 @@ def test_discrepancies(self):
         r = self.client.get(urlreverse("ietf.sync.views.discrepancies"))
         self.assertContains(r, doc.name)
 
+
 class RFCEditorUndoTests(TestCase):
     def test_rfceditor_undo(self):
         draft = WgDraftFactory()