Skip to content

Commit edd6ef4

Browse files
weiliciouschrisli30
authored andcommitted
fix: address Copilot PR #407 review comments
- Fix comment in testutil/utils.go to reflect actual panic behavior instead of fallback values - Improve aa_sender validation error message to include invalid value for better debugging - Simplify template resolution error message by moving explanation to log field - Enhance hyphen validation log message with specific guidance about valid variable paths - Update LoadSecretsForImmediateExecution comment to clarify user-level secrets limitation These changes improve code clarity, debugging capabilities, and user guidance based on GitHub Copilot feedback in PR #407.
1 parent 0f001cb commit edd6ef4

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

core/taskengine/vm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,7 @@ func (v *VM) preprocessTextWithVariableMapping(text string) string {
17041704
// - Variable names: settings.uniswap-pool (should be settings.uniswap_pool)
17051705
if isSimpleVariablePath(expr) && strings.Contains(expr, "-") {
17061706
if v.logger != nil {
1707-
v.logger.Warn("Template variable path contains invalid character (hyphen)", "expression", expr)
1707+
v.logger.Warn("Template variable path contains invalid character (hyphen) - use snake_case for simple variable paths", "expression", expr, "help", "Hyphens are only invalid in simple variable paths like 'settings.field-name'. Use 'settings.field_name' instead. Hyphens are allowed in complex expressions, string literals, and array indexing.")
17081708
}
17091709
result = result[:start] + "undefined" + result[end+2:]
17101710
continue

core/taskengine/vm_runner_contract_write.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (r *ContractWriteProcessor) executeMethodCall(
146146
return &avsproto.ContractWriteNode_MethodResult{
147147
MethodName: methodCall.MethodName,
148148
Success: false,
149-
Error: "aa_sender variable is set but invalid - must be a non-empty hex address string",
149+
Error: fmt.Sprintf("aa_sender variable is set but invalid - must be a non-empty hex address string, got: %v", aaSenderVar),
150150
}
151151
}
152152
} else {
@@ -171,12 +171,13 @@ func (r *ContractWriteProcessor) executeMethodCall(
171171
r.vm.logger.Error("❌ CONTRACT WRITE - Template variable failed to resolve",
172172
"method", methodCall.MethodName,
173173
"original_param", param,
174-
"resolved_param", resolvedMethodParams[i])
174+
"resolved_param", resolvedMethodParams[i],
175+
"explanation", "This may be due to an undefined variable, incorrect template syntax, or unsupported variable names (e.g., variables with hyphens are not supported; use snake_case such as 'recipient_address' instead of 'recipient-address').")
175176
}
176177
return &avsproto.ContractWriteNode_MethodResult{
177178
MethodName: methodCall.MethodName,
178179
Success: false,
179-
Error: fmt.Sprintf("template variable resolution failed in parameter %d: '%s' resolved to '%s'. This may be due to an undefined variable, incorrect template syntax, or unsupported variable names (e.g., variables with hyphens are not supported; use snake_case such as 'recipient_address' instead of 'recipient-address').", i, param, resolvedMethodParams[i]),
180+
Error: fmt.Sprintf("template variable resolution failed in parameter %d: '%s' resolved to '%s'", i, param, resolvedMethodParams[i]),
180181
}
181182
}
182183
}

0 commit comments

Comments
 (0)