Skip to content

Commit 4f7cae2

Browse files
committed
fix: correct format verb errors in error messages and logging output
Fixes multiple format string bugs found by auditing Go format verbs: - %ws typo in remove.go: %ws is not a valid Go verb; produces stray 's' in output - %w used in output.Errorf/Fatalf/Debugf: %w is only supported in fmt.Errorf; using it in fmt.Sprintf-based logging functions produces garbled %!w(...) output Affected files: pkg/cmd/remove/remove.go (%ws -> %w, %w -> %s) pkg/cmd/unpack/cmd.go (%w -> %v) pkg/cmd/info/cmd.go (%w -> %v) pkg/lib/filesystem/cache/cache.go (%w -> %s) pkg/lib/harness/llm-harness.go (%w -> %v) Verification: go vet, go build, go test all pass. Signed-off-by: Adesh Deshmukh <adeshkd123@gmail.com>
1 parent 85bf690 commit 4f7cae2

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

pkg/cmd/info/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func runCommand(opts *infoOptions) func(*cobra.Command, []string) error {
119119
} else {
120120
yamlBytes, err := config.MarshalToYAML()
121121
if err != nil {
122-
return output.Fatalf("Error formatting manifest: %w", err)
122+
return output.Fatalf("Error formatting manifest: %v", err)
123123
}
124124
fmt.Print(string(yamlBytes))
125125
}

pkg/cmd/remove/remove.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func removeAllModels(ctx context.Context, opts *removeOptions) error {
5757
// First untag all manifests for this digest
5858
for _, tag := range tags {
5959
if err := localRepo.Untag(ctx, tag); err != nil {
60-
output.Errorf("Failed to untag %s:%s: %w", repository, tag, err)
60+
output.Errorf("Failed to untag %s:%s: %s", repository, tag, err)
6161
}
6262
output.Infof("Untagged %s:%s", repository, tag)
6363
}
@@ -139,7 +139,7 @@ func removeModelRef(ctx context.Context, localRepo local.LocalRepo, ref *registr
139139
if err := ref.ValidateReferenceAsDigest(); err == nil || forceDelete {
140140
output.Debugf("Deleting manifest with digest %s", ref.Reference)
141141
if err := localRepo.Delete(ctx, desc); err != nil {
142-
return ocispec.DescriptorEmptyJSON, fmt.Errorf("failed to delete model: %ws", err)
142+
return ocispec.DescriptorEmptyJSON, fmt.Errorf("failed to delete model: %w", err)
143143
}
144144
return desc, nil
145145
}

pkg/cmd/unpack/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func runCommand(opts *unpackOptions) func(*cobra.Command, []string) error {
189189
}
190190
// Make sure target directory exists, in case user is using the -d flag
191191
if err := os.MkdirAll(opts.unpackDir, 0755); err != nil {
192-
return output.Fatalf("failed to create directory %s: %w", opts.unpackDir, err)
192+
return output.Fatalf("failed to create directory %s: %v", opts.unpackDir, err)
193193
}
194194
output.Infof("Unpacking to %s", unpackTo)
195195

pkg/lib/filesystem/cache/cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func MkCacheFile(subDir CacheSubDir, basename string) (tempFile *os.File, cleanu
8989
output.Errorf("Error closing temporary file %s: %s", tempFilePath, err)
9090
}
9191
if err := os.Remove(f.Name()); err != nil && !os.IsNotExist(err) {
92-
output.Errorf("Failed to remove temporary file %s: %w", tempFilePath, err)
92+
output.Errorf("Failed to remove temporary file %s: %s", tempFilePath, err)
9393
}
9494
}
9595
return f, cleanup, nil

pkg/lib/harness/llm-harness.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (harness *LLMHarness) Stop() error {
163163

164164
err = process.Signal(os.Interrupt) // Try to kill it gently
165165
if err != nil {
166-
output.Debugf("Error killing process %w", err)
166+
output.Debugf("Error killing process %v", err)
167167
// If SIGTERM failed, kill it with SIGKILL
168168
err = process.Kill()
169169
if err != nil {

0 commit comments

Comments
 (0)