Formula cycle detection: show full extends chain in error message (gt-8tmz.15)
When bd cook encounters a circular extends chain (A extends B extends A), the error message now shows the full chain: "cycle-a -> cycle-b -> cycle-a" instead of just "circular extends detected: cycle-a". This makes debugging circular dependencies much easier by showing exactly which formulas are involved in the cycle. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package formula
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -533,6 +534,18 @@ func TestResolve_CircularExtends(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Error("Resolve should fail for circular extends")
|
||||
}
|
||||
|
||||
// Verify the error message shows the full cycle chain
|
||||
errStr := err.Error()
|
||||
if !strings.Contains(errStr, "cycle-a") {
|
||||
t.Errorf("error should mention cycle-a: %v", err)
|
||||
}
|
||||
if !strings.Contains(errStr, "cycle-b") {
|
||||
t.Errorf("error should mention cycle-b: %v", err)
|
||||
}
|
||||
if !strings.Contains(errStr, "->") {
|
||||
t.Errorf("error should show cycle chain with '->': %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetStepByID(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user