From e71b11f8430d54f6e69742f3aaa41b2b36945881 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Mon, 17 Mar 2025 02:28:06 -0400 Subject: [PATCH] lang: funcs: facts: Check if a fact is callable --- lang/funcs/facts/func.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lang/funcs/facts/func.go b/lang/funcs/facts/func.go index 0c98b0be..13495a3b 100644 --- a/lang/funcs/facts/func.go +++ b/lang/funcs/facts/func.go @@ -97,5 +97,12 @@ func (obj *FactFunc) Stream(ctx context.Context) error { // Call this fact and return the value if it is possible to do so at this time. func (obj *FactFunc) Call(ctx context.Context, _ []types.Value) (types.Value, error) { - return obj.Fact.Call(ctx) + //return obj.Fact.Call(ctx) + + callableFact, ok := obj.Fact.(CallableFact) + if !ok { + return nil, fmt.Errorf("fact is not a CallableFact") + } + + return callableFact.Call(ctx) }