Skip to content

Conversation

@AlekSi
Copy link
Owner

@AlekSi AlekSi commented Dec 7, 2025

No description provided.

Copilot AI review requested due to automatic review settings December 7, 2025 08:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces packing/unpacking functionality for directories and adds a read-only archive-based cache implementation. However, the code contains several critical bugs that prevent compilation and correct execution.

Key changes:

  • Added internal/pack package with ZIP compression and decompression functions
  • Added internal/caches/archive package for read-only ZIP-backed cache
  • Updated documentation in internal/caches/local to clarify cache compatibility

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.

File Description
internal/pack/pack.go New package providing Pack/Unpack functions for ZIP compression of directories, with resource leak issue and commented-out code
internal/caches/local/local.go Documentation improvements clarifying compatibility with built-in cache
internal/caches/archive/archive.go New read-only ZIP-backed cache implementation with multiple critical bugs (incomplete struct field, uninitialized fields, unused function call, missing return value)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

type Cache struct {
zr *zip.Reader
c io.Closer
d
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Incomplete field declaration. The field d has no type specified, which will cause a compilation error.

Copilot uses AI. Check for mistakes.

// Get implements [cache.Cache].
func (c *Cache) Get(id cache.ActionID) (cache.Entry, error) {
return c.dc.Get(id)
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Undefined field access. The field c.dc is accessed but never initialized in the New or Open functions, which will cause a nil pointer dereference at runtime.

Copilot uses AI. Check for mistakes.
Comment on lines +159 to +163
dst.Close()
if err != nil {
resErr = lazyerrors.Error(err)
return
}
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Resource leak on error path. If f.Open() succeeds but an error is returned, the dst file handle is closed but its error is ignored. Consider checking the close error or using a deferred close with proper error handling.

Suggested change
dst.Close()
if err != nil {
resErr = lazyerrors.Error(err)
return
}
closeErr := dst.Close()
if err != nil {
resErr = lazyerrors.Error(err)
return
}
if closeErr != nil && resErr == nil {
resErr = lazyerrors.Error(closeErr)
return
}

Copilot uses AI. Check for mistakes.
}, nil
}

func Open(file string, l *slog.Logger) (*Cache, error) {
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

[nitpick] Function naming inconsistency. The function Open should be named consistently with Go conventions, such as OpenFile or NewFromFile, to clearly indicate it opens a cache from a file path. Additionally, it should have a documentation comment explaining its purpose.

Suggested change
func Open(file string, l *slog.Logger) (*Cache, error) {
// OpenFile opens a read-only Cache backed by a zip archive at the given file path.
func OpenFile(file string, l *slog.Logger) (*Cache, error) {

Copilot uses AI. Check for mistakes.
l: l,
}, nil
}

Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Missing documentation. The exported function Open lacks a documentation comment, which is required for all exported identifiers in Go.

Suggested change
// Open opens a zip archive file and returns a new [Cache].

Copilot uses AI. Check for mistakes.
return nil, lazyerrors.Error(err)
}

os.CreateTemp()
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Unused function call. os.CreateTemp() is called but its return values are ignored and the created temporary file is never used or cleaned up. This will create a resource leak.

Suggested change
os.CreateTemp()

Copilot uses AI. Check for mistakes.

// OutputFile implements [cache.Cache].
func (c *Cache) OutputFile(id cache.OutputID) string {
return c.dc.OutputFile(id)
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Undefined field access. The field c.dc is accessed but never initialized in the New or Open functions, which will cause a nil pointer dereference at runtime.

Copilot uses AI. Check for mistakes.

// FuzzDir implements [cache.Cache].
func (c *Cache) FuzzDir() string {
return
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Empty return value. The function should return a string representing the fuzz directory, but returns an empty value instead.

Suggested change
return
return ""

Copilot uses AI. Check for mistakes.
Comment on lines +138 to +143
// err = root.MkdirAll(fp[:len(fp)-len(f.FileInfo().Name())], 0o755)
// if err != nil {
// resErr = lazyerrors.Error(err)
// return
// }

Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Commented-out code should be removed. This block of code for creating parent directories appears to be incomplete work that should either be implemented or removed before merging.

Suggested change
// err = root.MkdirAll(fp[:len(fp)-len(f.FileInfo().Name())], 0o755)
// if err != nil {
// resErr = lazyerrors.Error(err)
// return
// }

Copilot uses AI. Check for mistakes.
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.

1 participant