Uploaded image for project: 'Archive of Our Own'
  1. Archive of Our Own
  2. AO3-4808

Error 500 when saving a work edited to have no fandom

    Details

    • Type: Bug
    • Status: Deployed
    • Priority: Medium
    • Resolution: DeployedToBeta
    • Affects Version/s: 0.9.172
    • Fix Version/s: 0.9.185
    • Milestone:
      Internal 0.9
    • Difficulty:
      Medium
    • Roadmap:
      Work
    • Components:
      BackEnd

      Description

      Apparently following some refactoring a couple of years ago, the following code on lines 440-450 at the end of the update action in the WorksController ceased to have any use:

              unless @chapter.valid?
                @chapter.errors.each { |err| @work.errors.add(:base, err) }
              end
      
              unless @work.has_required_tags?
                if @work.fandoms.blank?
                  @work.errors.add(:base, 'Updating: Please add all required tags. Fandom is missing.')
                else
                  @work.errors.add(:base, 'Updating: Required tags are missing.')
                end
              end
      

      The reason for this is the addition of the line return unless saved a few lines higher - this bails out of the action if the chapter is not valid (can't be saved) or if the work is lacking required tags. So even if the work isn't saved, it won't be for one of those reasons (as it wouldn't reach this part) so those additional errors will never be added as far as I can see.

      If we'd like the errors to be added, we could move this code up above return unless saved or take inspiration from the 2008 version of the code in Git history which used to wait until the very end of the method to return. It depends whether anyone has missed those errors when updating a work and making it invalid. Alternatively, we could remove this code.

      ETA: When testing the behaviour manually, we discovered that the line return unless saved actually causes the following 500 error as there is no template associated with the `update` action:

      method=POST path=/works/1059936 format=html controller=works action=update status=500 error='ActionView::MissingTemplate: Missing template works/update, application/update with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in:
        * "/home/ao3app/app/releases/20161231095818/app/views"
      ' duration=439.83
      

      Testing

      1. Edit a work that was previously posted
      2. Hit the "x" next to the only fandom tag to remove it
      3. Choose "Post Without Preview"

      You get an error 500 because of the above code situation.

        Attachments

          Activity

            People

            • Assignee:
              ariana Ariana
              Reporter:
              ariana Ariana
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: