feat(workflow): add json() template filter for webhook payload extraction - #2887
Open
genesis1tech wants to merge 1 commit into
Open
feat(workflow): add json() template filter for webhook payload extraction#2887genesis1tech wants to merge 1 commit into
genesis1tech wants to merge 1 commit into
Conversation
…tion Webhook payloads stringify nested objects whole, so templates could not reach fields inside them — a GitHub issues hook renders as one JSON blob. Add a json(PATH) filter that parses the value and walks a dot-separated path (json(body), json(user.login), json(labels.0.name)). Missing fields resolve to an empty string since payload shapes vary across providers; a non-JSON value is a template error. String results render unquoted. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Genesis 1 Technologies LLC <146556214+genesis1tech@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The webhook bridge flattens only top-level payload keys — nested objects arrive as one stringified blob (
crates/buzz-relay/src/bridge.rs). So a GitHubissueswebhook gives a template exactly one handle,{{trigger.issue}}, and the only filters available weretruncate()andnpub. A workflow that wants the issue title and body has to dump the entire JSON object into the message.Change
Adds a
json(PATH)filter toapply_filter:json(labels.0.name)).41,true).nullresolve to an empty string — payload shapes vary across providers and event types, so an absent optional field shouldn't fail the run.TemplateError: that means the template targets the wrong field, and failing loudly is right.No new dependencies (
serde_jsonis already in the crate).Test plan
Six unit tests in
executor.rscovering string extraction, non-string scalars, nested paths, array indexing, missing/null → empty, non-JSON value error, and empty path error.