AO3-7568 Fix error 500 when importing a work with a numeric date - #5983
AO3-7568 Fix error 500 when importing a work with a numeric date#5983hab-bang wants to merge 3 commits into
Conversation
851f990 to
5c0d73a
Compare
|
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! |
|
|
||
| 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)) |
There was a problem hiding this comment.
Can you call the method instead of using send?
@sp.convert_revised_at("300106")There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
I see now why you opted for send. Looks good, thank you!
Modify the story parser spec to use class_eval method so that the temporary visibility flip doesn't define a constant inside a block.
Pull Request Checklist
AO3-1234 Fix thing)Issue
https://otwarchive.atlassian.net/browse/AO3-7568
Purpose
Fixing the misspelled constant in
StoryParser#convert_revised_atthat 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 isRegexp, so it raisesuninitialized constant StoryParser::Regex. The method only rescuesArgumentErrorandTypeError, 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):
NameError: uninitialized constant StoryParser::Regex).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