Skip to content

feature: Improve testing experience for webhook transforms #745

@minitriga

Description

@minitriga

Component

infrahubctl CLI

Describe the Feature Request

Testing transforms that are used with webhooks is currently impractical because the data structure passed to the transform differs significantly between testing and production execution.

Describe the Use Case

When testing with infrahubctl transform:

  • The transform's query attribute is executed via GraphQL
  • The transform receives query results (structured as GraphQL response data)

When running in production (webhook triggered):

  • The transform's query attribute is required but completely ignored
  • The transform receives event payload data directly with structure:
    {
    "data": {"kind": "...", "action": "...", "node_id": "..."},
    "id": "event-uuid",
    "event": "infrahub.node.updated",
    "branch": None,
    "account_id": "account-uuid",
    "occured_at": "2025-03-13T16:31:14.566032+00:00"
    }

Why This Is a Problem

  1. Data structure mismatch: A transform that works correctly in testing will
    fail in production because it expects query-structured data but receives
    event-structured data
  2. No way to test with event data: There's no CLI command or testing mechanism
    to pass mock event payloads to a transform
  3. Confusing API: The query attribute is required on webhook transforms but
    serves no purpose
  4. False confidence: Passing tests don't guarantee the transform will work
    when triggered by actual webhooks

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions