Skip to content

Add Client-Side Pre-Upload Package Validation #1061

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

Merged
merged 6 commits into from
Jun 30, 2025
Merged

Conversation

x753
Copy link
Contributor

@x753 x753 commented Sep 9, 2024

Prevents users from attempting to upload packages that aren't zips or packages without a manifest, icon, and readme in the root of the zip.

Warns the user when uploading packages with > 8 DLL files, an Assembly-CSharp.dll file, or BepInEx.dll.

Fixes a chromium bug preventing the selection of a file that was previously selected and canceled.

image

@x753 x753 requested a review from MythicManiac September 9, 2024 18:08
@x753 x753 force-pushed the pre-upload-validation branch from d27ceb8 to 511181e Compare September 9, 2024 18:09
@x753 x753 force-pushed the pre-upload-validation branch from 511181e to d8bf267 Compare January 21, 2025 13:56
@x753 x753 force-pushed the pre-upload-validation branch from 8b7a454 to 7a6b794 Compare February 11, 2025 15:59
@Roffenlund
Copy link
Contributor

Roffenlund commented Feb 18, 2025

I cannot build this branch on my machine, it fails with the error [TypeScript error: /app/src/uploadZipValidation.ts(2,39): Error TS2306: File '/app/src/vendor/zip-fs-full.d.ts' is not a module.].

Would adding something like this to the uploadZipValidation.ts solve this instead of trying to import the file?

const zip = require('./vendor/zip-fs-full.js');

const BlobReader = zip.BlobReader;
const ZipReader = zip.ZipReader;

@x753 x753 force-pushed the pre-upload-validation branch from 7a6b794 to 7780955 Compare February 20, 2025 17:19
@x753
Copy link
Contributor Author

x753 commented Feb 20, 2025

I cannot build this branch on my machine, it fails with the error [TypeScript error: /app/src/uploadZipValidation.ts(2,39): Error TS2306: File '/app/src/vendor/zip-fs-full.d.ts' is not a module.].

Would adding something like this to the uploadZipValidation.ts solve this instead of trying to import the file?

const zip = require('./vendor/zip-fs-full.js');

const BlobReader = zip.BlobReader;
const ZipReader = zip.ZipReader;

As of 15c1243 it should build for you now. if your Builder-1 dies, just:

docker compose down
docker volume rm <built-static>
docker compose up builder
docker compose down
docker compose build
docker compose up

comment: string;
crc32: number;

getData(
writer: zip.Writer,
Copy link

Choose a reason for hiding this comment

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

The type reference zip.Writer should be updated to just Writer since the zip namespace declaration has been removed. This will align with the new export style used throughout the file and prevent potential type errors.

Suggested change
writer: zip.Writer,
writer: Writer,

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +102 to +103
writer: zip.Writer,
callback: (zipWriter: zip.ZipWriter) => void,
Copy link

Choose a reason for hiding this comment

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

The type references in this interface need to be updated to match the new export style. Since the zip namespace declaration has been removed, the parameter types should be changed from zip.Writer and zip.ZipWriter to just Writer and ZipWriter respectively to be consistent with the direct export approach used in the rest of the file.

Suggested change
writer: zip.Writer,
callback: (zipWriter: zip.ZipWriter) => void,
writer: Writer,
callback: (zipWriter: ZipWriter) => void,

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Copy link

codecov bot commented Jun 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.21%. Comparing base (a5bf591) to head (61cda5b).
Report is 7 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1061   +/-   ##
=======================================
  Coverage   92.21%   92.21%           
=======================================
  Files         331      331           
  Lines       10060    10060           
  Branches      926      926           
=======================================
  Hits         9277     9277           
  Misses        657      657           
  Partials      126      126           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

x753 added 6 commits June 25, 2025 10:40
Prevents users from attempting to upload packages that aren't zips or
packages without a manifest, icon, and readme in the root of the zip.

Warns the user when uploading packages with > 8 DLL files, an
Assembly-CSharp.dll file, or BepInEx.dll.

Fixes a chromium bug preventing the selection of a file that was
previously selected and canceled.
Move upload zip validation into separate file
Add wrongCase, wrongExtension, and noExtension errors
Remove unused exported variables from zip-fs-full.d.ts
Add check for "test" in file name so we can warn users to test locally first
@x753 x753 force-pushed the pre-upload-validation branch from 2071f7c to 61cda5b Compare June 25, 2025 14:40
@Roffenlund
Copy link
Contributor

I tested this again and encountered the following error when uploading a package:

2025-06-26 11:52:32.368 UTC [39] ERROR: null value in column "review_status" of relation "repository_packageversion" violates not-null constraint

There are no unapplied migrations in my development environment, and uploading a package works as expected on the master branch. A rebase onto master might resolve the issue.

Copy link
Contributor

@Roffenlund Roffenlund left a comment

Choose a reason for hiding this comment

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

See comment: #1061 (comment)

@x753
Copy link
Contributor Author

x753 commented Jun 26, 2025

I tested this again and encountered the following error when uploading a package:

2025-06-26 11:52:32.368 UTC [39] ERROR: null value in column "review_status" of relation "repository_packageversion" violates not-null constraint

There are no unapplied migrations in my development environment, and uploading a package works as expected on the master branch. A rebase onto master might resolve the issue.

I rebased yesterday so that's likely unrelated. This has also happened in the past: #1112 (review)

It doesn't make sense to me that this could happen seeing as how we have a default value in the migration. Could you try running docker compose down; docker compose build; docker compose up then see if the issue persists?

If it persists, I can't recreate this, so you could test:

  • Running tests to see if the same error occurs
  • Migrating back to Repository 0057 then migrating forward again

@Roffenlund Roffenlund merged commit ecabe87 into master Jun 30, 2025
27 checks passed
@Roffenlund Roffenlund deleted the pre-upload-validation branch June 30, 2025 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants