Skip to content

Commit 7a9bdf2

Browse files
committed
refactor: log a warning for undeclared variables in brick configuration
1 parent 4b525b3 commit 7a9bdf2

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

internal/orchestrator/app/validator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package app
33
import (
44
"errors"
55
"fmt"
6+
"log/slog"
67

78
"github.com/arduino/arduino-app-cli/internal/orchestrator/bricksindex"
89
)
@@ -27,7 +28,7 @@ func ValidateBricks(a AppDescriptor, index *bricksindex.BricksIndex) error {
2728
for appBrickName := range appBrick.Variables {
2829
_, exist := indexBrick.GetVariable(appBrickName)
2930
if !exist {
30-
allErrors = errors.Join(allErrors, fmt.Errorf("variable %q does not exist on brick %q", appBrickName, indexBrick.ID))
31+
slog.Warn("variable is referenced but not declared in the brick configuration", "variable", appBrickName, "brick", indexBrick.ID)
3132
}
3233
}
3334

internal/orchestrator/app/validator_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ func TestValidateAppDescriptorBricks(t *testing.T) {
6161
expectedError: errors.New("brick \"arduino:not_existing_brick\" not found"),
6262
},
6363
{
64-
name: "invalid if variable does not exist in the brick",
64+
name: "log a warning if variable does not exist in the brick",
6565
filename: "not-found-variable-app.yaml",
66-
expectedError: errors.New("variable \"NOT_EXISTING_VARIABLE\" does not exist on brick \"arduino:arduino_cloud\""),
66+
expectedError: nil,
6767
},
6868
}
6969

0 commit comments

Comments
 (0)