Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@WhippsP
Copy link
Contributor

@WhippsP WhippsP commented Sep 15, 2025

Removing single value revision numbers as that is against the naming standard (https://authors.ietf.org/naming-your-internet-draft#version) and causes issues with htmlized documents with -1 in the name (eg draft-ietf-oauth-v2-1).

Second Option - Update htmlized URL Ref directly

Removing single value revision numbers as that is against the naming standard (https://authors.ietf.org/naming-your-internet-draft#version) and causes issues with htmlized documents with -1 in the name (eg draft-ietf-oauth-v2-1)
Directly insert Regex for REV rather than reference settings.URL_REGEXPS. This is to resolve issue ietf-tools#9533
@codecov
Copy link

codecov bot commented Sep 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.85%. Comparing base (cbdd7ff) to head (7508225).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9538      +/-   ##
==========================================
+ Coverage   88.75%   88.85%   +0.10%     
==========================================
  Files         320      319       -1     
  Lines       41834    41807      -27     
==========================================
+ Hits        37128    37149      +21     
+ Misses       4706     4658      -48     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rjsparks
Copy link
Member

rjsparks commented Sep 17, 2025

This patch looks like it will improve the use case that motivated it without making the other edges worse. The branch survived a test crawl (a sample of a full crawl, but it's served us well in the past to expose unexpected behavior early).

One point to note: In fuzzy_find_documents:

datatracker/ietf/doc/utils.py

Lines 1212 to 1253 in c718718

def fuzzy_find_documents(name, rev=None):
"""Find a document based on name/rev
Applies heuristics, assuming the inputs were joined by a '-' that may have been misplaced.
If returned documents queryset is empty, matched_rev and and matched_name are meaningless.
The rev input is not validated - it is used to find possible names if the name input does
not match anything, but matched_rev may not correspond to an actual version of the found
document.
"""
# Handle special case name formats
if re.match(r"^\s*rfc", name, flags=re.IGNORECASE):
name = re.sub(r"\s+", "", name.lower())
if name.startswith('rfc0'):
name = "rfc" + name[3:].lstrip('0')
if name.startswith('review-') and re.search(r'-\d\d\d\d-\d\d$', name):
name = "%s-%s" % (name, rev)
rev = None
if rev and not name.startswith('charter-') and re.search('[0-9]{1,2}-[0-9]{2}', rev):
name = "%s-%s" % (name, rev[:-3])
rev = rev[-2:]
if re.match("^[0-9]+$", name):
name = f'rfc{name}'
if name.startswith("rfc"):
sought_type = "rfc"
name = name.split("-")[0] # strip any noise (like a revision) at and after the first hyphen
rev = None # If someone is looking for an RFC and supplies a version, ignore it.
else:
sought_type = "draft"
# see if we can find a document using this name
docs = Document.objects.filter(name=name, type_id=sought_type)
if sought_type == "draft" and rev and not docs.exists():
# No draft found, see if the name/rev split has been misidentified.
# Handles some special cases, like draft-ietf-tsvwg-ieee-802-11.
name = '%s-%s' % (name, rev)
docs = Document.objects.filter(name=name, type_id='draft')
if docs.exists():
rev = None # found a doc by name with rev = None, so update that
FoundDocuments = namedtuple('FoundDocuments', 'documents matched_name matched_rev')
return FoundDocuments(docs, name, rev)

There is one bit of code that will never be executed when called from document_html (it will still be reached when called from document_main and other views):

datatracker/ietf/doc/utils.py

Lines 1229 to 1231 in c718718

if rev and not name.startswith('charter-') and re.search('[0-9]{1,2}-[0-9]{2}', rev):
name = "%s-%s" % (name, rev[:-3])
rev = rev[-2:]

Arguably the real bug (or one facet of it) is those 3 lines, but the heuristic logic to deal with determining whether a string ending with a single or double digit is an attempt to reference the unversioned name of a document or a specific version of a document is currently spread between views that call each other and workarounds in those views compete with each other to introduce new unintended behavior. (If we could send messages back to the past, I think we'd strongly discourage overloading URL path segments with "this could be a name, or it could be a name with a version" entirely, but that expectation has been pushed into so many places, changing it is unfeasible).

But as noted in the issue, the workaround in this PR is making one case better without obviously making other cases worse, and unless a second set of eyes on it turns up something, I expect to merge it.

When we rebuild these views, further moving these heuristics into a place where the effect of changes can be tested more easily than they can be now will happen.

Copy link
Member

@jennifer-richards jennifer-richards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that this fixes the corner case without much risk of breaking in unexpected places.

@rjsparks rjsparks merged commit acffceb into ietf-tools:main Sep 17, 2025
15 of 16 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants