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

bug: error: System.NullReferenceException: Object reference not set to an instance of an object #13

Closed
davykinger opened this issue Aug 13, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@davykinger
Copy link

Bug Report

Version:

1.1.0.0

Current behavior:

An error occurs, I believe, upon calling ZipArchive (line 851). However, I have not been able to debug due to reference issues with a few dependencies/packages. See error below:

13-08-2024 15:06:49 - [EventID 1001] Error Exception caught when trying to save file to disk: 'C:\Temp\ADOBackup\13-08-2024-(15-06)\DevOps Initiative_AttunityTest_master_blob.zip' - Azure DevOps Backup Log 13-08-2024.log.
at AzureDevOpsBackup.Program.

d__1.MoveNext()

Expected behavior:

I believe this should unzip the blobs into useable folders and files

Steps to reproduce:

The following command is run from the file location of the AzureDevOpsBackup.exe:
.\AzureDevOpsBackup.exe --token "" --org "" --backup "C:\Temp\ADOBackup" --server "smtp.bailliegifford.com" --port "25" --from "" --to "" --unzip --cleanup

Related code:

Full error log attached

Other information:

A generic point about using ZipArchive is made here (following a user experiencing the same issue) - https://stackoverflow.com/questions/33687425/central-directory-corrupt-error-in-ziparchive

@davykinger davykinger added the bug Something isn't working label Aug 13, 2024
@davykinger
Copy link
Author

Update - I finally got this running locally and debugged the code. An exception occurs at:

Line 457 - ZipArchive.cs:

System.IO.InvalidDataException
  HResult=0x80131501
  Message=Central Directory corrupt.
  Source=System.IO.Compression
  StackTrace:
   at System.IO.Compression.ZipArchive.ReadEndOfCentralDirectory() in System.IO.Compression\ZipArchive.cs:line 457
   at System.IO.Compression.ZipArchive.Init(Stream stream, ZipArchiveMode mode, Boolean leaveOpen) in System.IO.Compression\ZipArchive.cs:line 357
   at System.IO.Compression.ZipFile.Open(String archiveFileName, ZipArchiveMode mode, Encoding entryNameEncoding)
   at System.IO.Compression.ZipFile.OpenRead(String archiveFileName)
   at AzureDevOpsBackup.Program.<Main>d__1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at AzureDevOpsBackup.Program.<Main>(String[] args)

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
IOException: An attempt was made to move the file pointer before the beginning of the file.

GitHub CoPilot suggests:

_This error happens because the Central Directory of the ZIP archive is corrupt. The InvalidDataException is thrown when the ZipArchive class attempts to read the end of the central directory but encounters data that doesn't match the expected format.
This might be happening because:

  1. The ZIP file is incomplete or has been corrupted during transfer or storage.
  2. The file pointer is moved incorrectly, causing the Seek operation to fail.
  3. The ZIP file might be using a format or compression method not supported by the System.IO.Compression library.
    To resolve this issue, you can:
  4. Verify the integrity of the ZIP file and ensure it is not corrupted.
  5. Check if the file pointer is being moved correctly before reading the central directory.
  6. Ensure that the ZIP file is not using an unsupported format or compression method.
    Additional information needed:
  7. The exact code used to open and read the ZIP file.
  8. Details about how the ZIP file is created and transferred._

I will continue to debug locally but any response is appreciated

@michaelmsonne
Copy link
Owner

I will look into it @davykinger and get back.

@michaelmsonne
Copy link
Owner

Hi @davykinger,

I have looked into this and can't reproduce this behavior - unfortunately.

Humming the tool here every night and have the same arguments set also.

How is the structure of the repository it's trying to download?

@davykinger
Copy link
Author

Hi @michaelmsonne

Thanks for looking into it

The repo's structure in this case is entirely empty - might this be causing the problem?

@michaelmsonne
Copy link
Owner

Hi @davykinger ,

Yes that can be it - I will see into the code and see if there is something to do :)

@michaelmsonne
Copy link
Owner

@davykinger any updates on the repo's structure?

@davykinger
Copy link
Author

@michaelmsonne the repo doesn't have a structure. It is entirely empty i.e. without a read.me or gitignore. We put in some logic to skip empty repos but experienced further errors, we are going to have to move on so feel free to close this issue

@michaelmsonne
Copy link
Owner

Will see if I can manage to fix it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants