Skip to content

Commit

Permalink
Fix: Fix panicking when file cannot be opened or is empty (#173)
Browse files Browse the repository at this point in the history
* better log error handling

(cherry picked from commit 3d17f76)

* Update receiver/githubactionsreceiver/log_event_handling.go

Co-authored-by: Horst Gutmann <[email protected]>

* Update receiver/githubactionsreceiver/log_event_handling.go

Co-authored-by: Horst Gutmann <[email protected]>

---------

Co-authored-by: Giordano Ricci <[email protected]>
Co-authored-by: Horst Gutmann <[email protected]>
  • Loading branch information
3 people authored Nov 19, 2024
1 parent 31da4e7 commit f796444
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion receiver/githubactionsreceiver/log_event_handling.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"archive/zip"
"bufio"
"context"
"fmt"
"io"
"net/http"
"os"
Expand Down Expand Up @@ -64,9 +65,16 @@ func eventToLogs(event interface{}, config *Config, ghClient *github.Client, log
return nil, err
}

archive, _ := zip.OpenReader(out.Name())
archive, err := zip.OpenReader(out.Name())
if err != nil {
return nil, fmt.Errorf("failed to open zip file: %w", err)
}
defer archive.Close()

if archive.File == nil {
return nil, fmt.Errorf("archive is empty")
}

// steps is a map of job names to a map of step numbers to file names
var jobs = make([]string, 0)
var files = make([]*zip.File, 0)
Expand Down

0 comments on commit f796444

Please sign in to comment.