Skip to content

substrate export and substrate debug never load the event store, so both report zero events #879

Closed

Description

@scttfrdmn

substrate export and substrate debug both read the event store's in-memory slice and never call EventStore.Load, so against a file or sqlite backend each reports zero events for a stream that was recorded successfully. debug is worse: it ignores the configured backend entirely.

This is the same one-line cause as #855's first defect, at two more commands. #855 covers replay only, so these two are filed separately — and a shared Load in one place covers all three.

export exports nothing from a persistent backend

newExportCmd (cmd/substrate/main.go:330-410) constructs the store from config at :350:

	store := substrate.NewEventStore(cfg.EventStore.ToEventStoreConfig())

and then calls store.ExportNDJSON (:389) or store.ExportCSV (:387). Both delegate to GetEvents (eventstore.go:500, :520 → :482), which filters the in-memory e.events slice. Load (:769) is never called, so the slice is empty and the export writes an empty document — exit status 0, and with --output - (the default) not even the exported %d events line on stderr, since that is printed only when writing to a file (:394-396).

The failure mode is the worst kind: a successful command with an empty result. A user exporting a recorded run for a regression fixture — one of the documented reasons the event log exists — gets a valid, empty NDJSON file and no indication anything is wrong.

debug ignores the configured backend outright

newDebugCmd (:480-536) loads the config and then discards it (:496):

			_ = cfg // used for future persistence options

			store := substrate.NewEventStore(substrate.EventStoreConfig{
				Enabled: true,
				Backend: "memory",
			})

A freshly constructed memory-backend store in a new process has no events by construction, so GetStream (:504 → eventstore.go:586) always returns none and the command always prints (:510):

stream "<id>" contains no events

under help text that says "List events recorded in a stream and print their details." There is no configuration and no argument that makes it print an event. Note this one is not fixed by adding Load alone — the hardcoded config has to go first.

Acceptance criteria

  • export calls EventStore.Load before reading, so a file or sqlite backend exports the events it recorded.
  • debug builds its store from cfg.EventStore rather than a hardcoded memory backend, and loads it. The _ = cfg line goes.
  • The load path is shared with replay (substrate replay wires an empty registry, a nil state manager, and never loads the events #855) rather than pasted three times, so the three commands cannot drift.
  • export distinguishes "no events matched the filter" from "the store was never loaded" — a zero-event export against a non-empty backend must not exit 0 silently.
  • A test per command: record a stream to a file backend in one store, then run each command's wiring path against that path in a fresh store and assert a non-zero event count. Both assertions fail today.

Found while verifying #855 for the v0.116.0 cut.

Activity

  1. added this to the v0.116.0 milestone on Sep 15, 2026
  2. added
    type: bug
    on Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions