GoogleContainerTools/skaffold · error
writing string: %w
Error message
writing string: %w
What it means
After successful marshalling, SaveEventsToFile writes each serialized event plus a newline with f.WriteString. Failure is wrapped as 'writing string: %w'. Since the file was just opened for append/write, failures are almost always I/O-level (disk full, closed file, device error).
Source
Thrown at pkg/skaffold/event/event.go:851
handler.logLock.Lock()
// Ensure that the filepath provided has the directories available when attemping to save the file.
dir := filepath.Dir(fp)
if err := os.MkdirAll(dir, 0700); err != nil {
return fmt.Errorf("unable to create directory %q: %w", dir, err)
}
f, err := os.OpenFile(fp, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
return fmt.Errorf("opening %s: %w", fp, err)
}
defer f.Close()
marshaller := jsonpb.Marshaler{}
for _, ev := range handler.eventLog {
contents := bytes.NewBuffer([]byte{})
if err := marshaller.Marshal(contents, ev); err != nil {
return fmt.Errorf("marshalling event: %w", err)
}
if _, err := f.WriteString(contents.String() + "\n"); err != nil {
return fmt.Errorf("writing string: %w", err)
}
}
handler.logLock.Unlock()
return nil
}
View on GitHub (pinned to a1189de023)
Solutions
- Check free disk space (df -h) on the filesystem holding the output file and free space if needed
- Write the event log to a different filesystem with available space
- Check storage quota (quota -s) if on a quota-limited home or network volume
- Retry after the transient I/O condition clears — the file is opened in append mode so partial logs persist
Defensive patterns
Strategy: retry
Try / catch
var lastErr error
for attempt := 0; attempt < 3; attempt++ {
if err := SaveEventsToFile(fp); err == nil {
return nil
} else if strings.Contains(err.Error(), "writing string") {
lastErr = err
time.Sleep(time.Second)
continue
}
return err
}
return lastErr Prevention
- Monitor disk space on the volume holding event logs
- Keep event logs on durable local storage rather than flaky network mounts
- Keep event log size bounded for long sessions
- Treat write failures as transient and retry; the file is opened in append mode
When it happens
Trigger: Disk becomes full (ENOSPC) mid-write; underlying storage error on network volumes; file descriptor closed or invalidated by an external process during the loop.
Common situations: Small tmpfs or container overlay filling up during long skaffold sessions with many events; NFS/EFS volumes dropping connections; quota exceeded on user storage.
Related errors
- writing string: %w
- unable to create directory %q: %w
- opening %s: %w
- unable to create directory %q: %w
- opening %s: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/f64c06ba8c64fe39.
Report an issue: GitHub.