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

WebHost: Prevent committing data packages with invalid checksums to database and prevent 500 error from invalid zip files. #3206

Merged
merged 1 commit into from
Apr 27, 2024

Conversation

ThePhar
Copy link
Member

@ThePhar ThePhar commented Apr 24, 2024

What is this fixing or adding?

This is a two-fold PR just because both fixes were trivial.

  1. Prevent committing data packages with invalid checksums to database.

    If a game with a data package checksum that does not match the re-calculated checksum is uploaded, an error would flash on the screen with the specific error, but the data package would still be uploaded to the database. Then the next time a user uploads the same game data package, it will return a 500 error instead as PONY would throw an exception.

    The fix was to compare the checksums first, then create a GameDataPackage entity as doing it before would still commit to DB even without running commit.

  2. Prevent 500 error from invalid zip files.

    Similar to the above, if a .zip file containing the .archipelago file with the invalid data package checksums was uploaded, it would return a 500 error regardless. This was because there was no base Exception catch. We just add the base Exception catch and flash the same error message as above.

Error discovered in this tech support thread: https://discord.com/channels/731205301247803413/1232485200542433423

Adding affects: release/blocker as without this change, DB will still be polluted with bad checksum data.

Ideally the whole GameDataPackage table in the DB should also be run through for invalid data packages with mismatched checksums to remove existing bad entries, but that's a @Berserker66 request since I don't have access to the server. :P Edit: Actually impossible to check because upload.py overrides the checksum from the uploaded file in both column and data package. So unless the rest of the data package is invalid, it probably can't be detected (but may be fine anyway?).

How was this tested?

Ran WebHost and uploaded generations with invalid data packages and valid data packages.

  • The valid ones would work and still write new data packages to DB.
  • The invalid ones would not work, but shows a nicer error message at least.

If this makes graphical changes, please attach screenshots.

No pictures of my database for you. Just trust me bro.

image

…atabase and prevent 500 error from invalid `zip` files.
@ThePhar ThePhar added is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs. affects: release/blocker Issues/PRs that must be addressed before next official release. affects: webhost Issues/PRs that touch webhost and may need additional validation. labels Apr 24, 2024
@github-actions github-actions bot added the waiting-on: peer-review Issue/PR has not been reviewed by enough people yet. label Apr 24, 2024
@Berserker66
Copy link
Member

image
#3207

@ThePhar ThePhar merged commit e76ba92 into ArchipelagoMW:main Apr 27, 2024
16 checks passed
jnschurig pushed a commit to Tranquilite0/Archipelago-SoulBlazer that referenced this pull request Jun 13, 2024
…atabase and prevent 500 error from invalid `zip` files. (ArchipelagoMW#3206)
qwint pushed a commit to qwint/Archipelago that referenced this pull request Jun 24, 2024
…atabase and prevent 500 error from invalid `zip` files. (ArchipelagoMW#3206)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: release/blocker Issues/PRs that must be addressed before next official release. affects: webhost Issues/PRs that touch webhost and may need additional validation. is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs. waiting-on: peer-review Issue/PR has not been reviewed by enough people yet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants