Version of copa
main built from source
Expected Behavior
When copa patches a multi platform image whose manifest index contains a child entry that has no platform field, copa should skip that entry and keep discovering the remaining valid platforms.
Actual Behavior
copa crashes with a nil pointer dereference panic.
The code path is DiscoverPlatformsFromReference in pkg/buildkit/buildkit.go around lines 399 and 400. The branch that is meant to skip entries with a missing or unknown platform still reads m.Platform.OS and m.Platform.Architecture inside the log call. Go evaluates those arguments before the log function runs, and logrus evaluates them regardless of the current log level, so a nil platform is dereferenced and the process panics.
The failing code looks like this
if m.Platform == nil || m.Platform.OS == "unknown" || m.Platform.Architecture == "unknown" {
log.Debugf("Skipping manifest with unknown platform: %s/%s", m.Platform.OS, m.Platform.Architecture)
continue
}
The panic message is
runtime error invalid memory address or nil pointer dereference
A manifest index can legitimately contain entries with no platform field, for example attestation or provenance entries, so any such image triggers this.
Steps To Reproduce
- Build copa from source on main
- Prepare a multi platform image whose index has at least one child manifest with no platform field, for example an attestation entry
- Run copa patch on that image with no report so the platform discovery path runs
- copa panics instead of skipping the entry and patching the valid platforms
Are you willing to submit PRs to contribute to this bug fix?
Version of copa
main built from source
Expected Behavior
When copa patches a multi platform image whose manifest index contains a child entry that has no platform field, copa should skip that entry and keep discovering the remaining valid platforms.
Actual Behavior
copa crashes with a nil pointer dereference panic.
The code path is DiscoverPlatformsFromReference in pkg/buildkit/buildkit.go around lines 399 and 400. The branch that is meant to skip entries with a missing or unknown platform still reads m.Platform.OS and m.Platform.Architecture inside the log call. Go evaluates those arguments before the log function runs, and logrus evaluates them regardless of the current log level, so a nil platform is dereferenced and the process panics.
The failing code looks like this
The panic message is
A manifest index can legitimately contain entries with no platform field, for example attestation or provenance entries, so any such image triggers this.
Steps To Reproduce
Are you willing to submit PRs to contribute to this bug fix?