Skip to content

AO3-7568 Fix error 500 when importing a work with a numeric date - #5983

Open
hab-bang wants to merge 3 commits into
otwcode:masterfrom
hab-bang:AO3-7568-error-500-importing-work-with-numeric-date
Open

AO3-7568 Fix error 500 when importing a work with a numeric date#5983
hab-bang wants to merge 3 commits into
otwcode:masterfrom
hab-bang:AO3-7568-error-500-importing-work-with-numeric-date

Conversation

@hab-bang

@hab-bang hab-bang commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-7568

Purpose

Fixing the misspelled constant in StoryParser#convert_revised_at that returns an Error 500 when a work's date is a plain number.

The method treats an all-digit date as seconds since the epoch. That branch calls Regex.last_match, but the class is Regexp, so it raises uninitialized constant StoryParser::Regex. The method only rescues ArgumentError and TypeError, so the error escapes the import and the user gets a 500.

Testing Instructions

Follow the reproduction steps on the Jira issue (Post > Import Work with the gist URL from the ticket, and any language):

  • Before this change: Error 500 (NameError: uninitialized constant StoryParser::Regex).
  • After this change: the work imports and you get the work preview.

The date shows as 1970-01-04, because the parser reads an all-numeric date as a Unix timestamp. That is existing behaviour and is not changed here, so it is expected.

Full testing instructions are also on the Jira ticket.

References

Reported from Sentry, issue AO3-STAGING-8Y.

Credit

Name: Woo Hayoung
Pronouns: she/her

@hab-bang
hab-bang force-pushed the AO3-7568-error-500-importing-work-with-numeric-date branch from 851f990 to 5c0d73a Compare August 17, 2026 01:58
@sarken

sarken commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Hi, hayoung!

Thanks for working on this. It looks like this was submitted with an outdated version of the pull request template. Before we review this, could you take a moment to edit the description to use the new Pull Request Checklist, which includes a new checkbox about our AI policy? The new template is here: https://github.com/otwcode/otwarchive/blob/master/.github/PULL_REQUEST_TEMPLATE.md

Thanks!

@hab-bang

Copy link
Copy Markdown
Contributor Author

Hi, hayoung!

Thanks for working on this. It looks like this was submitted with an outdated version of the pull request template. Before we review this, could you take a moment to edit the description to use the new Pull Request Checklist, which includes a new checkbox about our AI policy? The new template is here: https://github.com/otwcode/otwarchive/blob/master/.github/PULL_REQUEST_TEMPLATE.md

Thanks!

Hi @sarken ! Firstly I'm sorry for using the old template; I didn't realize that the template has been updated and I still used the same one I used for my first PR. My apologies!

I have updated my PR description and included the checkbox about the AI policy, and I can confirm that I do not submit the code with the help of AI.

If you have questions or other stuff related to this PR that you want me to work on, please let me know!

Comment thread spec/models/story_parser_spec.rb Outdated

describe "#convert_revised_at" do
it "converts an all-digit date to a Time" do
expect(@sp.send(:convert_revised_at, "300106").to_date).to eq(Date.new(1970, 1, 4))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you call the method instead of using send?

@sp.convert_revised_at("300106")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@redsummernight thank you for the review--it means I'll have to modify the before(:all) and after(:all) to make the method public and then back to protected. Working on this now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see now why you opted for send. Looks good, thank you!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you so much @redsummernight !

@redsummernight redsummernight changed the title AO3-7568 Fix Error 500 when importing a work with a numeric date AO3-7568 Fix error 500 when importing a work with a numeric date Aug 21, 2026
Modify the story parser spec to use class_eval method so that the temporary visibility flip doesn't define a constant inside a block.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants