Unverified Commit 390a3397 authored by julienmancuso's avatar julienmancuso Committed by GitHub
Browse files

fix: do not fail if backendFramework cannot be detected (#2655)

parent 266265ea
......@@ -1012,7 +1012,7 @@ func detectBackendFrameworkFromArgs(command []string, args []string) (BackendFra
}
if len(detected) == 0 {
return "", fmt.Errorf("no backend framework detected from command: %q", fullCommand)
return BackendFrameworkNoop, nil
}
if len(detected) > 1 {
......@@ -1059,13 +1059,13 @@ func determineBackendFramework(
}
// Validate consistency if both detected and explicit exist
if detectedFramework != "" && explicitFramework != "" && detectedFramework != explicitFramework {
if detectedFramework != "" && detectedFramework != BackendFrameworkNoop && explicitFramework != "" && detectedFramework != explicitFramework {
return "", fmt.Errorf("backend framework mismatch: detected %q from command but explicitly configured as %q",
detectedFramework, explicitFramework)
}
// Return in order of preference: detected > explicit > error
if detectedFramework != "" {
if detectedFramework != "" && detectedFramework != BackendFrameworkNoop {
return detectedFramework, nil
}
......@@ -1079,7 +1079,7 @@ func determineBackendFramework(
}
// No command/args to detect from and no explicit config
return "", fmt.Errorf("backend framework must be specified explicitly or detectable from command/args")
return BackendFrameworkNoop, nil
}
// getBackendFrameworkFromComponent attempts to determine backend framework using hybrid approach:
......
......@@ -3629,7 +3629,7 @@ func TestDetectBackendFrameworkFromArgs(t *testing.T) {
name: "no backend detected",
command: []string{"/bin/sh", "-c"},
args: []string{"echo hello world"},
expectError: true,
expected: BackendFrameworkNoop,
},
{
name: "multiple backends detected",
......@@ -3709,17 +3709,17 @@ func TestDetermineBackendFramework(t *testing.T) {
errorContains: "backend framework mismatch",
},
{
name: "worker with no detection, no explicit - returns error",
name: "worker with no detection, no explicit - returns noop",
componentType: "worker",
expectError: true,
errorContains: "backend framework must be specified explicitly or detectable from command/args",
expected: BackendFrameworkNoop,
expectError: false,
},
{
name: "worker with detection failure, no explicit - returns error",
name: "worker with detection failure, no explicit - returns noop",
componentType: "worker",
args: []string{"echo hello world"},
expectError: true,
errorContains: "could not determine backend framework",
expected: BackendFrameworkNoop,
expectError: false,
},
}
......@@ -3843,18 +3843,18 @@ func TestGetBackendFrameworkFromComponent(t *testing.T) {
expected: BackendFrameworkNoop,
},
{
name: "worker with no detection, no explicit - returns error",
name: "worker with no detection, no explicit - returns noop",
component: &v1alpha1.DynamoComponentDeploymentOverridesSpec{
DynamoComponentDeploymentSharedSpec: v1alpha1.DynamoComponentDeploymentSharedSpec{
ComponentType: "worker", // Worker component
},
},
deployment: &v1alpha1.DynamoGraphDeployment{},
expectError: true,
errorContains: "backend framework must be specified explicitly or detectable from command/args",
expected: BackendFrameworkNoop,
expectError: false,
},
{
name: "worker with detection failure, no explicit - returns error",
name: "worker with detection failure, no explicit - returns noop",
component: &v1alpha1.DynamoComponentDeploymentOverridesSpec{
DynamoComponentDeploymentSharedSpec: v1alpha1.DynamoComponentDeploymentSharedSpec{
ComponentType: "worker", // Worker component
......@@ -3866,8 +3866,8 @@ func TestGetBackendFrameworkFromComponent(t *testing.T) {
},
},
deployment: &v1alpha1.DynamoGraphDeployment{},
expectError: true,
errorContains: "could not determine backend framework",
expected: BackendFrameworkNoop,
expectError: false,
},
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment