Skip to content

Commit d1d33ac

Browse files
committed
fix: make code_file required for transformations
Reverts the implicit dist/index.js default — users must explicitly declare where their transformation code lives.
1 parent 875ac5b commit d1d33ac

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

pkg/deploy/deploy.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,16 +358,14 @@ func buildConnectionRequest(conn *manifest.ConnectionConfig, sourceID, destinati
358358
}
359359

360360
// resolveCode reads the code file for a transformation.
361-
// If CodeFile is empty, defaults to "dist/index.js" (standard esbuild output).
362361
func resolveCode(tr *manifest.TransformationConfig, codeRoot string) (string, error) {
363-
codeFile := tr.CodeFile
364-
if codeFile == "" {
365-
codeFile = "dist/index.js"
362+
if tr.CodeFile == "" {
363+
return "", fmt.Errorf("code_file is required")
366364
}
367365

368-
path := codeFile
366+
path := tr.CodeFile
369367
if codeRoot != "" {
370-
path = codeRoot + "/" + codeFile
368+
path = codeRoot + "/" + tr.CodeFile
371369
}
372370

373371
// For now we pass the code_file path as the code value. In the real deploy

pkg/deploy/deploy_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package deploy
33
import (
44
"context"
55
"fmt"
6+
"strings"
67
"testing"
78

89
"github.com/toppynl/hookdeck-deploy-cli/pkg/manifest"
@@ -131,6 +132,22 @@ func TestDeploy_DryRun_ConnectionWithRules(t *testing.T) {
131132
}
132133
}
133134

135+
func TestDeploy_MissingCodeFile(t *testing.T) {
136+
m := &manifest.Manifest{
137+
Transformation: &manifest.TransformationConfig{
138+
Name: "no-code-file",
139+
},
140+
}
141+
142+
_, err := Deploy(context.Background(), &mockClient{}, m, Options{})
143+
if err == nil {
144+
t.Fatal("expected error when code_file is missing, got nil")
145+
}
146+
if !strings.Contains(err.Error(), "code_file is required") {
147+
t.Errorf("expected error to contain %q, got %q", "code_file is required", err.Error())
148+
}
149+
}
150+
134151
// --- mock client tests (live mode with mock) ---
135152

136153
type mockClient struct {

schemas/hookdeck-transformation.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
}
4444
}
4545
},
46-
"required": ["name"],
46+
"required": ["name", "code_file"],
4747
"additionalProperties": false
4848
},
4949
"env": {

0 commit comments

Comments
 (0)