Skip to content

feat(cli): add tole webhook test to check a destination end to end - #931

Merged
ajianaz merged 16 commits into
developfrom
feat/webhook-test-cmd
Nov 18, 2026
Merged

ajianaz merged 16 commits into
developfrom
feat/webhook-test-cmd

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Part 5a of #911: tole webhook test NAME sends one signed webhook_test event to a destination of the user config and prints what the receiver answered. tole doctor still makes no network call; this is the explicit one.

Why

A gateway operator who has just configured a destination needs to know the URL, the secret and the receiver's signature check work, without waiting for a cron run to fire. Until now the only way to find out was a real run.

Changes

  • tole webhook test NAME: the destination is a name from [webhook_out.NAME]; there is no flag for a URL, a header or a secret, so it cannot be pointed anywhere the owner did not declare. One request, no retry, no outbox, no ledger row. Exits non-zero unless the receiver answered 2xx.
  • The event is signed with the same native v2 scheme as every event (webhook_out::probe, built on sign::request_headers), with id test:<16 hex> so it can be found in the receiver's log, type: "webhook_test" and the destination inside the signed body.
  • The output is the destination name, the event id and an HTTP status or a closed code (timeout, dns, transport, refused_address, redirect_refused, bad_destination): never the URL (which can carry a token), a header, the key or any text the receiver sent. A name typed on the command line is printed as printable ASCII only.
  • Event::WebhookTest is not in Event::ALL: it cannot be listed in events, and a forged outbox line cannot name it (the sender's validation does not recognise it).
  • The network, the key source and the clock are injected (probe takes a Poster and Keys), as in the sender. CHANGELOG entry.

Testing

  • 6 unit tests for probe (signature over exactly the sent bytes, ids unique per nonce, the closed result table, an unknown destination or a missing key sends nothing, not a configurable event, nothing secret in the body or the outcome) and 2 for the printed report.
  • 7 tests on the real binary with a receiver thread that verifies the headers and the v2 signature itself: delivered and reported; a 500 fails the command, is not retried and echoes nothing; a closed port reports a code, not a URL; an unknown name lists the known ones and sends nothing; control characters in a typed name cannot forge a line; a missing secret is reported without sending; no destinations says where to declare one. In each, neither the URL token nor the key is in the output, and nothing is queued.
  • Full cargo test -p tole-cli passes, clippy clean, layering test passes (webhook_cmd is registered as a face module).

Part 4b of #911. webhook_out::send::drain_pass leases one due event per
destination through the store, sends with no lock held, and appends the
result under a short lock.

Before every send the line is re-validated against the destination of the
loaded config and signed with the key that destination names, so a
forged line cannot choose a destination, an event type or a key, and the
key is not read for a line that fails validation. A result line and its
terminal line are one write, and a send must end inside its lease.

Retry and no-retry follow the design; result codes are a closed set and
no receiver text is stored or printed. The network, the key source and
the clock are injected.

Nothing calls it yet.
… standalone tick

Part 4c of #911. A webhook:<name> target is now delivered. The tick (and
an approval-resumed run, which goes through the same path) only appends
the redacted cron_run_finished event to the outbox; the sender writes the
ledger delivery row when the event settles. A silent ok run records
skipped, a failed run with no output still notifies, and a refusal to
queue records failed with a closed code.

The standalone tole cron tick and tole cron run send for about 20 s after
their jobs. A row is written once per run and destination and only for a
run whose job names the destination. The destination URL is redacted
like its key. Events of a destination that is no longer configured are
never sent and never make a drain wait.
Part 4e of #911. reconcile closes the two gaps a crash leaves: a run that
settled but whose event was never queued, and an event that finished
without a ledger row. A row of any status counts as terminal, so a silent
run is not queued again.

A run younger than 10 minutes is left to the live tick. A missing kept
output is never read as silent, and the file is read without following a
symlink or blocking on a FIFO. A webhook row is written once per run and
destination by the live tick too. It runs at the start of tole serve and
every 5 minutes, and before the drain of a standalone tick.
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 6ecbd4d into develop Nov 18, 2026
19 checks passed
@ajianaz
ajianaz deleted the feat/webhook-test-cmd branch November 20, 2026 08:38
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.

1 participant