Skip to content

Save/init ignore SQL execution errors, causing silent data-loss on failure #63

Description

@kavix

Description

cmd/init.go and cmd/save.go both call database.Exec(...) and discard
the returned error:

// init.go
database.Exec(`CREATE TABLE IF NOT EXISTS snapshots (...)`)
// save.go
database.Exec(
	"INSERT INTO snapshots(id, message, path) VALUES (?, ?, ?)",
	id, saveMessage, path,
)
fmt.Println("Snapshot saved:", id)

If the INSERT fails for any reason (locked DB, disk full, schema issue),
save.go still prints Snapshot saved: <id> — the user believes the
snapshot is recorded, but eko history / eko restore will never find it,
even though the file tree under .eko/snapshots/<id>/ was actually written.

Suggested fix

Check the error from every Exec call and surface it:

if _, err := database.Exec(...); err != nil {
	return fmt.Errorf("failed to record snapshot: %w", err)
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions