Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fall back to _x filename for beta release notes #1455

Merged
merged 3 commits into from
Nov 18, 2024
Merged

Conversation

GregKaleka
Copy link
Collaborator

@GregKaleka GregKaleka commented Nov 18, 2024

Follow-up fix for #1171

It turns out the newest beta release notes have been named version_1_87_x.html instead of the expected version_1_87_0.html name. This PR creates a fallback strategy that first attempts the _0 filename, then tries _x if the former results in a 404 response.

Manual testing

I wasn't able to successfully test the S3 version of the function, since the beta release notes do not yet appear to be in S3.

For the GitHub version, I added a print statement for debug purposes to indicate we were hitting the fallback url with the _x filename suffix.

In [1]: v = Version.objects.last()

In [2]: v.slug
Out[2]: 'boost-1-87-0-beta1'

In [3]: from versions.releases import get_release_notes_for_version_github

In [4]: html = get_release_notes_for_version_github(v.pk)
normal url failed; trying fallback

In [5]: html[:100]
Out[5]: b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n    "http://www.w3.org/TR/xhtml1/DTD/xhtml1'

Copy link
Member

@rbbeeston rbbeeston left a comment

Choose a reason for hiding this comment

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

I'm good with this, please ping Brian or Dave to get it reviewed. I want this to get in the merge today

settings.STATIC_CONTENT_BUCKET_NAME,
f"release-notes/master/{filename}.adoc",
)
s3_client = get_s3_client()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd think we should tweak this so we have a set of alternative strings/formats checked in a while loop, that way there's flexibility for adding new ones in the future, and we only have the call code once.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I considered this, but

  1. I wasn't really sure what other patterns might exist, making it a bit difficult to generalize, and
  2. YAGNI - I figured we could add this once we have more than two known possible patterns

If you think we should still add this now, I'm open to doing so, though we will still need a code change to at a minimum add the third pattern if it crops up. LMK your thoughts.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Personally I'd have it not repeat the code in both places, but it will work as is so I've approved the PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fair - I have a feeling we'll be revisiting this code, and I'll keep this in mind. I'm going to add a TODO comment but merge this as-is for now. Thanks Dave!

try:
response = session.get(url)
if response.status_code == 404:
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here, with the try catch inside the while

@GregKaleka GregKaleka merged commit 12cfb3a into develop Nov 18, 2024
4 checks passed
@GregKaleka GregKaleka deleted the issue-1171-a branch November 18, 2024 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants