buzz icon indicating copy to clipboard operation
buzz copied to clipboard

buzz workflows delete accepted but deleted workflows still appear in list/get (and update resurrects them)

Open Paradoxia opened this issue 3 months ago • 6 comments

Describe the bug buzz workflows delete returns accepted:true and the relay logs Workflow deleted via NIP-09 a-tag (UUID), but the workflow still appears in buzz workflows list and buzz workflows get afterwards. Worse, a subsequent buzz workflows update with the same workflow UUID succeeds and "resurrects" the workflow. The CLI's list/get paths query kind:30620 events, which are never tombstoned by the NIP-09 deletion.

Steps to reproduce

  1. buzz workflows create --channel <UUID> --yaml 'name: t\ntrigger: {on: webhook}\nsteps:\n - id: s1\n action: send_message\n text: hi' → note workflow_id (e.g. e4103c08-…)
  2. buzz workflows delete --workflow e4103c08-… → returns {"accepted":true,...}
  3. buzz workflows list --channel <UUID> → the workflow is STILL listed
  4. buzz workflows get --workflow e4103c08-… → still returns the full definition
  5. buzz workflows update --channel <UUID> --workflow e4103c08-… --yaml '...' → succeeds, and get now returns the updated definition (record resurrected from the still-queryable event)

Observed on 2026-08-05 against relay build ghcr.io/block/buzz:main (v0.2.0, image built 2026-08-01): 50 workflows deleted in a loop, all logged "Workflow deleted via NIP-09 a-tag (UUID)" at the relay, all still returned by list/get afterwards.

Expected behavior After a successful workflows delete, the workflow should no longer appear in list/get, and update should fail with not-found rather than resurrecting it.

Root-cause pointers (from source)

  • CLI delete sends a NIP-09 event with a tag 30620:<pubkey>:<workflow-id>: crates/buzz-cli/src/commands/workflows.rs (cmd_delete_workflow)
  • Relay deletes the workflows DB row and invalidates the channel cache: crates/buzz-relay/src/handlers/side_effects.rs (handle_a_tag_deletion)
  • CLI list/get query kind:30620 events via the event store: crates/buzz-cli/src/commands/workflows.rs (cmd_list_workflows, cmd_get_workflow) — the kind:30620 definition events are never tombstoned/filtered, so deleted workflows keep being returned (and any new kind:30620 with the same d-tag re-upserts the record).

Version and platform

  • Buzz version: v0.2.0 (relay image ghcr.io/block/buzz:main, built 2026-08-01; CLI from the same tree)
  • OS: macOS host running the relay in Docker (docker-compose buzz-prod)

Logs / additional context Relay log after each delete: {"level":"INFO","message":"Workflow deleted via NIP-09 a-tag (UUID)","workflow_id":"e4103c08-…","target":"buzz_relay::handlers::side_effects"}. Deletion events do not carry an error; the silent divergence between DB state and event-query state is the issue.

Paradoxia avatar Aug 05 '26 09:08 Paradoxia

Reproduced this locally against main (8342dfc) — all three symptoms, plus one detail worth adding to the report.

The resurrection re-arms the webhook with a new secret:

$ buzz workflows update --channel <ch> --workflow 04542aa7-… --yaml '…'
{"accepted":true,"message":"response:{\"webhook_secret\":\"a72a890c-…\",\"workflow_id\":\"04542aa7-…\"}"}

So a deleted webhook-triggered workflow isn't just visible — it comes back live with a freshly issued secret.

On the root cause: your pointer to handle_a_tag_deletion is right. Worth noting the fix isn't CLI-specific — desktop/src-tauri/src/commands/workflows.rs (get_channel_workflows / get_channels_workflows / get_workflow) queries kind:30620 exactly like the CLI does, so the desktop Workflows screen shows deleted workflows too. Tombstoning the definition event relay-side fixes every client at once.

One nuance on the expected behavior. The report asks that update fail with not-found. Agreed on the outcome, but that part can't be enforced in the relay: kind:30620 is parameterized-replaceable, so publishing a definition for a deleted workflow is a valid NIP-33 republish — rejecting it would violate the NIP. It seems better handled at the CLI layer, where update means "modify an existing workflow".

I have a fix with e2e coverage and will open a PR shortly. One question for a maintainer, since the fix touches a documented decision — the generic NIP-33 branch says:

Listed after the workflow branch so workflow's bespoke deletion (which doesn't soft-delete the events row by design — that's a separate concern) takes precedence.

My read is that "by design" describes the workflows row being separate, and leaving the definition event queryable was an unintended consequence rather than an invariant. If that's wrong and the live event is load-bearing for something, let me know and I'll rework the approach.

Pratikkale26 avatar Aug 05 '26 12:08 Pratikkale26

Fixed by PR #5051.

Root cause: workflows delete (kind:5 a-tag deletion) removed the workflows table row but never tombstoned the kind:30620 event rows, which are what list/get actually query. Re-publishing the coordinate (update) then inserted a fresh live event + recreated the DB row — resurrecting the workflow and re-arming its webhook secret.

Fix (live-verified):

  1. On delete, the relay now also soft-deletes the kind:30620 events by coordinate → list/get return nothing.
  2. Re-publishing a tombstoned coordinate is rejected (HTTP 400 "was deleted and cannot be re-published") instead of resurrecting.

This covers both the CLI and the desktop (which query the same kind:30620 event path, per the reproduction note in this issue). Regression test added — verified it fails on the pre-fix binary and passes with the fix.

yippietheproducer avatar Aug 06 '26 13:08 yippietheproducer

Fresh data point on Buzz Desktop 0.5.17 / hosted relay 0.2.1, plus a workaround that does remove the row.

Confirming the report, including for the workflow's own author. The community owner deleted his own workflow from the Desktop ... menu: the UI reported success and the workflow was still listed after a refresh. From the CLI, buzz workflows delete --workflow <uuid> returns

{"accepted":true,"event_id":"...","message":""}

and the workflow survives. Reproduced by creating a throwaway workflow and deleting it seconds later under the same key, so it is not a permissions problem. Note the empty message, where create and update both return a response:{"workflow_id":"..."} payload - the handler looks like it accepts the event and never acts on it.

Deleting a workflow you do not own fails loudly and correctly, which is worth separating out from this bug: CLI 400 conflict: workflow revision does not exist, Desktop 400 Bad Request: forbidden: workflow belongs to a different owner or channel.

Workaround that does work. Publish a NIP-09 tombstone against the workflow's current event, signed by its author:

buzz messages delete --event <latest event id for that workflow>

The workflow disappears from buzz workflows list immediately. Verified on four workflows across two keys.

Two things make it hard to reach in practice:

  • it must be the latest event. Once an update has superseded the create, the original create event returns event <id> not found;
  • neither workflows list nor workflows get returns an event id, so the only source is the event_id field in the response of the create or update call that last wrote it - which a user has no reason to have kept.

Exposing the current event_id on workflows list / workflows get would make the workaround usable in the meantime, and is presumably also what a fixed workflows delete needs to target.

sian72 avatar Aug 20 '26 23:08 sian72

Reproduced on a Block-hosted community as of 2026-08-21 (relay reports version 0.2.1). Host and workflow identifiers omitted here; happy to supply them privately if that helps.

Two things I don't think are on the issue yet:

1. Buzz Desktop hits the same failure, so this is not CLI-side.

buzz workflows delete returned {"accepted": true} on four separate attempts and the workflows remained in both workflows list and workflows get. Deleting the same entries from the Workflows tab in Buzz Desktop left them in the list too. Both clients read the kind:30620 definition, and both keep seeing it, which lines up with the tombstone analysis above rather than with anything client-specific.

2. workflows update still succeeds on a workflow that was just "deleted".

After a delete returned accepted: true, buzz workflows update against the same workflow id was accepted and returned response:{"workflow_id":"…"}, and the following list showed the new YAML under that id. That is consistent with @Pratikkale26's reading — the definition event is never tombstoned, so the projection row is re-upserted from the still-live event — i.e. the path #4882 is fixing.

Operational impact worth recording: since delete is inert, the only way to neutralise a stale scheduled workflow today is update with enabled: false. That does work, and it is the workaround I ended up using. But update appears to be author-scoped: updating a workflow authored by a different pubkey in the same channel was rejected with

relay error 400: conflict: workflow revision does not exist

I saw this on two workflows created by another member of the channel — one that had a delete attempted against it and one that had not been touched — while updates to workflows I had authored myself succeeded. I did not test this as the channel owner or as a relay operator, so I can only say it fails for an ordinary member.

The practical consequence is that in a shared channel, a stale scheduled workflow created by an agent or by someone who has since left cannot be removed or disabled by anyone else. Both the fix and the workaround are unavailable to them.

yamkz avatar Aug 21 '26 09:08 yamkz

Still reproduces on relay 0.2.1 (hosted *.communities.buzz.xyz) as of 2026-09-15 a month after the "Fixed by PR #5051" comment above.

Flagging that comment as stale, since it is probably why this reads as resolved: #5051 was closed on 2026-08-12 without merging (mergedAt: null). Of the fix candidates raised in this thread and #2879, #2489, #3392 and #4901 are all closed unmerged too; #4882 is the only one still open, and it is also unmerged. So as far as I can tell nothing has landed.

Trigger-probe, no intervening update

Confirms the split diagnosis in #2879, the engine-side delete works, only the read path lies:

$ buzz workflows delete --workflow ccd4a80b-…
{"accepted":true,"event_id":"d7269ea9…","message":""}

$ buzz workflows list --channel <ch>      # still present
$ buzz workflows get  --workflow ccd4a80b-…
{"content":"name: gilfoyle-identity-probe\ntrigger:\n  on: webhook\n…"}

$ buzz workflows trigger --workflow ccd4a80b-…
{"error":"relay_error","message":"relay error 400: invalid: workflow not found"}

This distinguishes the symptom here from #6554, which reports deleted workflows still firing. On 0.2.1 they do not fire, they are only undead in list/get.

Webhook secret re-arming, independently reproduced

Confirming @Pratikkale26's detail, now on 0.2.1. Same workflow, across a delete → update resurrection:

create            -> webhook_secret affc8894-f010-4746-8b63-aa637f30dfbd
delete ×2         -> {"accepted":true} each time
update            -> webhook_secret c58ffb9f-ffbc-482c-b842-28034cafaefa   # new

Operationally this is the sharp edge, and worth calling out for anyone driving a workflow webhook from an external monitor: the resurrected workflow comes back live with a different secret, so the external caller keeps POSTing with the old one and is rejected. If the workflow's job was to deliver alerts, the channel that would have told you it broke is the one that broke. Plain update calls with no preceding delete did not rotate the secret in my runs (3/3 returned no new secret), so the rotation appears specific to the resurrection path.

Also note buzz workflows get never returns the secret, it is only in the create/update responses, so a silently rotated secret is unrecoverable from the CLI.

Knock-on

A workflow that cannot be removed cannot be replaced cleanly either. Iterating on a definition leaves a growing pile of undead entries in list and in the Desktop Workflows panel, with no CLI way to tell which one is live.

Xeoneid avatar Sep 15 '26 21:09 Xeoneid

Fixed by https://github.com/block/buzz/pull/7735

ngthuydiem avatar Oct 13 '26 19:10 ngthuydiem