From d14431386dcae66a189653b2912ae46b75502de9 Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Wed, 20 Aug 2025 09:28:01 +0200 Subject: [PATCH 1/2] tools/zstpak: name file in error message If coredump tests fail because of a file with an unexected format, we get the following error: ``` failed to open coredump file reader: failed to open local file: file doesn't appear to be in zstpak format (bad magic) ``` Enrich the returned error message with the file name, to help debug this issue. Now it looks like this: ``` failed to open coredump file reader: failed to open local file: modulecache/09d5bc25045e77dd69e76304b8babc5b0bc85abda959a8c65cd3a3d9b471bdd0: file doesn't appear to be in zstpak format (bad magic) ``` Signed-off-by: Florian Lehner --- tools/zstpak/lib/zstpak.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/zstpak/lib/zstpak.go b/tools/zstpak/lib/zstpak.go index 87f14586b..b137e00d9 100644 --- a/tools/zstpak/lib/zstpak.go +++ b/tools/zstpak/lib/zstpak.go @@ -183,7 +183,7 @@ func Open(path string) (*Reader, error) { hdr, err := readFooter(file, uint64(fileInfo.Size())) if err != nil { - return nil, err + return nil, fmt.Errorf("%s: %v,", path, err) } return &Reader{ From 9b78676432f9c1f2f09fff97a8550b6a013b2501 Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Wed, 20 Aug 2025 11:01:06 +0200 Subject: [PATCH 2/2] fixup: move filename in error message to caller Signed-off-by: Florian Lehner --- tools/coredump/modulestore/store.go | 2 +- tools/zstpak/lib/zstpak.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/coredump/modulestore/store.go b/tools/coredump/modulestore/store.go index 5b7d62dd7..a18b2eb5f 100644 --- a/tools/coredump/modulestore/store.go +++ b/tools/coredump/modulestore/store.go @@ -138,7 +138,7 @@ func (store *Store) OpenReadAt(id ID) (*ModuleReader, error) { file, err := zstpak.Open(localPath) if err != nil { - return nil, fmt.Errorf("failed to open local file: %w", err) + return nil, fmt.Errorf("failed to open local file %s: %w", localPath, err) } reader := &ModuleReader{ diff --git a/tools/zstpak/lib/zstpak.go b/tools/zstpak/lib/zstpak.go index b137e00d9..87f14586b 100644 --- a/tools/zstpak/lib/zstpak.go +++ b/tools/zstpak/lib/zstpak.go @@ -183,7 +183,7 @@ func Open(path string) (*Reader, error) { hdr, err := readFooter(file, uint64(fileInfo.Size())) if err != nil { - return nil, fmt.Errorf("%s: %v,", path, err) + return nil, err } return &Reader{