abiosoft/colima · error

error saving store: %w

Error message

error saving store: %w

What it means

store.Set wraps every failure of its trailing save() call. The surrounding code shapes this error: a Load failure is merely logged (via a malformed logrus.Debug call that misuses %w, which logrus does not expand) and Set continues with a possibly empty Store — so a corrupt store file is silently replaced with defaults before the write result is even known.

Source

Thrown at store/store.go:62

	if err := os.WriteFile(storeFile(), b, 0o644); err != nil {
		return fmt.Errorf("error writing store file: %w", err)
	}

	return nil
}

// Set provides an easy way to set a value in the store.
func Set(f func(*Store)) error {
	s, err := Load()
	if err != nil {
		logrus.Debug("error loading store: %w", err)
	}

	f(&s)

	if err := save(s); err != nil {
		return fmt.Errorf("error saving store: %w", err)
	}

	return nil
}

// Reset resets the values in the store to the defaults.
func Reset() error {
	// first attempt to remove store file
	if err := os.Remove(storeFile()); err != nil {
		// if it fails
		// then attempt to set it to empty value
		return Set(func(s *Store) { *s = Store{} })
	}

	return nil
}

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Fix the underlying save failure first: permissions on the store dir, disk space
  2. If the existing store file is corrupt, delete it so Load starts from defaults instead of the swallowed-error path
  3. Patch Set to return the Load error instead of ignoring it (the logrus.Debug call is also malformed — it takes no format verbs)

Example fix

// before
s, err := Load()
if err != nil {
	logrus.Debug("error loading store: %w", err)
}
f(&s)

// after
s, err := Load()
if err != nil {
	return fmt.Errorf("error loading store: %w", err)
}
f(&s)
Defensive patterns

Strategy: try-catch

Try / catch

if err := store.Set(func(s *store.Store) { s.Flag = true }); err != nil {
	if strings.Contains(err.Error(), "error saving store") {
		// persistence-layer failure: fix perms/disk; re-read state before retrying — the swallowed Load path may have reset it
	}
}

Prevention

When it happens

Trigger: Any store write under the marshal/write failure conditions (permissions, disk); additionally a corrupt existing store file whose Load error was swallowed, leaving Set to operate on an empty Store.

Common situations: Root-owned store files from sudo runs; corrupt store JSON after an interrupted write; full disks.

Related errors


AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15). Data as JSON: /api/errors/1d2590fda3bd522a. Report an issue: GitHub.