Skip to content

rest: conditional create/update/delete emit no subscription events; no-match conditional delete audits no entity #862

Description

@aacruzgon

Summary

The conditional HTTP handlers write resources without emitting subscription events, so rest-hook (and every other channel) subscribers miss creates, updates and deletes performed via If-None-Exist, PUT [type]?[criteria], or DELETE [type]?[criteria]. Discussion #59 defines the event evaluator as running "on each resource write (create/update/delete)".

Evidence

  • crates/rest/src/handlers/create.rs:232-243 emits emit_subscription_event(..., ResourceEventType::Create) on the unconditional path only. The If-None-Exist branch (:117-205) returns before reaching it, so a resource created by conditional create is never announced.
  • update.rs: update_handler emits at :285-300 (Create or Update depending on created). conditional_update_handler (:333-464) contains no subscription_engine reference; both the Updated arm and the created-by-upsert arm are silent.
  • delete.rs: the instance path emits emit_delete_event at :201-212; conditional_delete_handler (:239-307) emits nothing.
  • patch.rs: patch_handler emits at :146-156; conditional_patch_handler does not. (That handler currently has no route; see the PATCH issue.)

Related audit gap in the same handler: conditional_delete_handler's NoMatch arm (delete.rs:298-301) answers 204 without an AuditResponseContext, so a no-match conditional delete is audited with no entity. The Deleted arm was fixed in #860.

Proposed fix

Emit through the same helpers the unconditional handlers use, in each conditional success arm (Created, Exists is not a write, Updated, Deleted). Add an AuditResponseContext naming the resource type on NoMatch. Tests: a rest-hook subscription receiving a notification for each conditional interaction (the subscriptions crate's channel tests are the model).

Found while validating #511 (see PR #860).

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions