Skip to content

Normalize since/date-range parsing across substreams logs commands - #222

Open
maoueh wants to merge 1 commit into
developfrom
feature/normalize-substreams-logs-connection-s--command
Open

Normalize since/date-range parsing across substreams logs commands#222
maoueh wants to merge 1 commit into
developfrom
feature/normalize-substreams-logs-connection-s--command

Conversation

@maoueh

@maoueh maoueh commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

firecore tools substreams logs connection (singular) and logs connections (plural) handled time ranges through two unrelated interfaces — a positional [<date-range>] argument on one, a --since/--date-range flag pair on the other — with incompatible parsers underneath. Copying a value between the two broke, most visibly --since 2d on connections, which Go's native time.Duration flag parser rejects outright (no d unit).

  • logs connection now takes --since/--date-range flags instead of a positional date-range argument, matching logs connections.
  • Both commands share the same parsing: --since is a relative duration (30m, 2h, 1d, 1w, "1 day ago", …), --date-range accepts slash, colon, or bare-timestamp forms.
  • All three commands (connection, connections, reexec) gained a 1w shortcut. Units are fixed-length to dodge calendar ambiguity: d == 24h, w == 7d == 168h.
  • logs reexec keeps its positional date-range argument (out of scope here) but shares the same underlying relative-duration parser, so 1w works there too.

Net effect: a since/date-range value copied from a logs connections listing straight into logs connection <trace-id> --since .../--date-range ... now works unchanged — the workflow this was built around.

Trade-offs

  • logs connection's date-range is no longer a positional argument — this is a breaking CLI change for that command, done deliberately to normalize with logs connections rather than keep two shapes.
  • Dropped the undocumented "trailing slash means open-ended end" form (--date-range "2024-01-15T10:00:00Z/") — a bare timestamp without any separator already means the same thing.

Test plan

  • go build ./...
  • go test ./cmd/...
  • Manually exercised logs connection <trace-id> --since 1w, logs connections --since garbage (clean error), --date-range with colon separator via go run ./cmd/firecore tools substreams logs ...

logs connection and logs connections handled time ranges through two
unrelated interfaces with incompatible parsers, so a value copied
between them broke — most visibly --since 2d on connections, which
Go's native time.Duration parser rejects (no d unit).

logs connection now takes --since/--date-range flags instead of a
positional date-range argument, matching logs connections. Both share
one relative-duration/date-range parser now, and all three commands
(connection, connections, reexec) gained a 1w shortcut (d == 24h,
w == 7d == 168h, fixed-length to avoid calendar ambiguity).
@sduchesneau

sduchesneau commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🔍 Vulnerabilities of ghcr.io/streamingfast/firehose-core:9de0fb4-amd64

📦 Image Reference ghcr.io/streamingfast/firehose-core:9de0fb4-amd64
digestsha256:76f1bc5db9dda1a40ef5dd1adba7071870570f998662e3242389a5b5164a069a
vulnerabilitiescritical: 0 high: 0 medium: 0 low: 0
platformlinux/amd64
size160 MB
packages509
📦 Base Image ubuntu:24.04
also known as
  • c1ca75be10a22ea09ff0b7bbe8b82ee03553a4f9b795030ee2ec921e42418fc8
  • noble
  • noble-20260810
digestsha256:1e0a86e57d247923571b75e0aaf48a1449cf8c543d51fb3e07a4a7d7bfa79316
vulnerabilitiescritical: 0 high: 0 medium: 3 low: 4

cmd.Flags().String("backend", "gcp", "Log backend to use (currently only 'gcp' supported)")
cmd.Flags().Duration("since", time.Duration(0), "Look back duration (e.g., '1h', '30m', '2d'). Mutually exclusive with --date-range")
cmd.Flags().String("date-range", "", "Date range in format '<start>[/<end>]'. End defaults to now. Mutually exclusive with --since")
cmd.Flags().String("since", "", sinceFlagHelp)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's weird with those two flags possibly doing the same thing..

functionally identical:

--since=1h
--date-range=1h

maybe we should have just --since= and --until= ?
like:

--since=24h and --until=1h
--since=2026-05-21T10:23:12Z and --until=2026-05-22T10:23:12Z

We could also accept --since=24h and --until=+2h30m

So there wouldn't be overlap between the function of both flags.

Either you use just --since with a duration (most common case for "last x hours")
Either you use both with durations --since=48h --until=24h (sous-entendu: "ago")
Either you use timestamps
Either you use timestamp for since, and use an until that is relative to the since (with + prefix)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants