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

Prevent failing import from file system from deleting assessment files #1945

Merged
merged 4 commits into from
Jul 25, 2023

Conversation

20wildmanj
Copy link
Contributor

@20wildmanj 20wildmanj commented Jul 18, 2023

Summary

Summary generated by Reviewpad on 25 Jul 23 04:32 UTC

This pull request includes three patches.

The first patch (PATCH 1/3) makes changes to the assessments_controller.rb file. It adds a check to ensure that each assessment has an associated yaml file with a name field that matches the filename. It also handles errors when displaying existing assessments.

The second patch (PATCH 2/3) also modifies the assessments_controller.rb file. It updates the comments to clarify the requirements for each assessment's associated yaml file, and it fixes some formatting issues.

The third patch (PATCH 3/3) addresses comments from a previous pull request. It renames the isTarImport parameter to cleanup_on_failure and updates the corresponding code. It also improves error handling and removes unnecessary code.

Overall, these patches enhance the functionality and error handling of the assessments_controller.rb file.

Description

  • use isTarImport parameter toimportAssessment to determine whether import is from tarball (aka from importAsmtTar) or from file system
  • delete assessment files only is import was from a tarball import, otherwise leave files as-is
  • Add pre-check in install_assessment to check for invalid name field in yaml to prevent installation of invalid assessment (and thus prevent yaml from getting wiped out, which happens if the error was only caught during deserialization)

Motivation and Context

How Has This Been Tested?

  • Delete existing assessment (go to "Edit Assessment"->"Delete Assessment")
  • Find assessment in file system, navigate to yaml, change name field to not match filename
  • Go to "Install Assessment," see following error appears and that assessment doesn't show up under "Import from File System"
    Screenshot 2023-07-17 at 9 43 24 PM
  • Fix the yaml name, then change config rb module name so that it doesn't match the filename / assessment name
  • Try installing the assessment, see following error:
    Screenshot 2023-07-17 at 9 46 42 PM
  • verify that assessment directory is still there

Regression:

  • import from tarball a buggy assessment (such as spec/fixtures/assessments/homework02-yaml-name-field-wrong.tar), and try importing it
  • see error is displayed and that assessment directory is deleted from course directory
  • Upload a normal tarball / import from file system a normal directory and see that import succeeds
  • Run bundle exec rake spec multiple times and see that tests pass

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have run rubocop for style check. If you haven't, run overcommit --install && overcommit --sign to use pre-commit hook for linting

@20wildmanj 20wildmanj self-assigned this Jul 18, 2023
@reviewpad reviewpad bot added small Pull request is small waiting-for-review labels Jul 18, 2023
Copy link
Member

@damianhxy damianhxy left a comment

Choose a reason for hiding this comment

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

Followed testing plan successfully, LGTM (other than some comments)

app/controllers/assessments_controller.rb Outdated Show resolved Hide resolved
app/controllers/assessments_controller.rb Outdated Show resolved Hide resolved
@20wildmanj 20wildmanj added this pull request to the merge queue Jul 25, 2023
Merged via the queue into master with commit c4ca573 Jul 25, 2023
5 of 6 checks passed
@20wildmanj 20wildmanj deleted the joeywildman-fix-import-assessment-deletion branch July 25, 2023 04:38
NicholasMy pushed a commit to UB-CSE-IT/Autolab that referenced this pull request Jan 4, 2024
autolab#1945)

* avoid deleting assessment files on non-tarball based imports

* rubocop

* Address PR comments, rename isTarImport param to be cleanup_on_failure

(cherry picked from commit c4ca573)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
small Pull request is small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assessment directory deleted as side effect of "Error loading yaml: Name in yaml doesn't match"
2 participants