GitLab project import crashes when the .tar.gz file is invalid instead of saying that the file is invalid

I hesitated between bug and feature proposal... Went with bug because of the error message.

Summary

Project import accepts any .tar.gz file and crashes with an unhelpful error message. The crash is normal, I want to address the error message with this issue.

Context

I was testing an issue that required me to modify my GitLab project file export and I did a mistake while repackaging (I included the directory in the archive instead of only the files). The error wasn't very descriptive and I lost a fair bit of time trying to understand the bug. I understand that modifying an archive is certainly not a common usage scenario and if you feel like no normal user will ever do that feel free to dismiss this bug.

Steps to reproduce

  1. Create a dummy .tar.gz file echo 'this is a test' > testfile && tar czvf testfile.tar.gz testfile
  2. New Project page
  3. Import Project button
  4. Gitlab Export button
  5. Pick a group and import the file from step 1

What is the current bug behavior?

This is displayed in https://gitlab.com/:group/:project/-/import/new
image

What is the expected correct behavior?

A message saying the archive is invalid similar to the message we get when trying to import a file that isn't a .tar.gz file.

Output of checks

This bug happens on GitLab.com

Possible fixes

Make sure all the archive files (GITLAB_REVISION, GITLAB_VERSION, VERSION, lfs-objects.json, project.bundle, project.json) are present in the uploaded file before processing.

Edited by Dominic Couture