Skip to content

Commit b15780a

Browse files
authored
Merge pull request #486 from pcbeingused333/fix/transformation-execution-fields
fix(transformations): keep the execution fields the API returns
2 parents 596d781 + af723c8 commit b15780a

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

‎pkg/hookdeck/transformations.go‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,16 @@ func (r *TransformationRunResponse) ConsoleText() string {
138138
type TransformationExecution struct {
139139
ID string `json:"id"`
140140
CreatedAt time.Time `json:"created_at"`
141-
// Additional fields may be present from API
141+
142+
// The remaining fields are what the execution endpoints return besides the
143+
// ID. The event payloads and logs are kept as raw JSON so their shape is
144+
// passed through untouched, including by `--output json`.
145+
WebhookID string `json:"webhook_id,omitempty"`
146+
IssueID string `json:"issue_id,omitempty"`
147+
LogLevel string `json:"log_level,omitempty"`
148+
OriginalEventData json.RawMessage `json:"original_event_data,omitempty"`
149+
TransformedEventData json.RawMessage `json:"transformed_event_data,omitempty"`
150+
Logs json.RawMessage `json:"logs,omitempty"`
142151
}
143152

144153
// TransformationExecutionListResponse represents the response from listing executions

‎pkg/hookdeck/transformations_test.go‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package hookdeck
22

3-
import "testing"
3+
import (
4+
"encoding/json"
5+
"testing"
6+
)
47

58
// TestTransformationRunResponse_Failed pins the success predicate against
69
// behaviour observed from the live API. The cases below are transcribed from
@@ -82,3 +85,30 @@ func TestTransformationRunResponse_ConsoleText(t *testing.T) {
8285
})
8386
}
8487
}
88+
89+
func TestTransformationExecution_KeepsAPIFields(t *testing.T) {
90+
body := `{"id":"exec_1","created_at":"2026-01-02T03:04:05Z","webhook_id":"web_1","issue_id":"iss_1","log_level":"error",` +
91+
`"original_event_data":{"body":{"a":1}},"transformed_event_data":{"body":{"a":2}},"logs":[{"type":"error","message":"boom"}]}`
92+
93+
var e TransformationExecution
94+
if err := json.Unmarshal([]byte(body), &e); err != nil {
95+
t.Fatal(err)
96+
}
97+
if e.WebhookID != "web_1" || e.IssueID != "iss_1" || e.LogLevel != "error" {
98+
t.Fatalf("scalar fields lost: %+v", e)
99+
}
100+
101+
out, err := json.Marshal(e)
102+
if err != nil {
103+
t.Fatal(err)
104+
}
105+
var got map[string]json.RawMessage
106+
if err := json.Unmarshal(out, &got); err != nil {
107+
t.Fatal(err)
108+
}
109+
for _, k := range []string{"original_event_data", "transformed_event_data", "logs", "log_level", "webhook_id", "issue_id"} {
110+
if _, ok := got[k]; !ok {
111+
t.Errorf("field %q missing from re-encoded execution: %s", k, out)
112+
}
113+
}
114+
}

0 commit comments

Comments
 (0)